/* ===== Module Stock (menu "Stock") — reprend les couleurs de style.css ===== */
#view-stock { --stk-warn: #a8660f; --stk-warn-soft: #fcefd6; --stk-ok: #2e7d4f; --stk-ok-soft: #e1f2e7; }

.stk-nav-badge {
  margin-left: auto; background: var(--amber); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 9px; padding: 1px 7px; line-height: 1.5; font-variant-numeric: tabular-nums;
}

#view-stock .stk-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
#view-stock .stk-head .subtitle { margin-bottom: 18px; }
#view-stock .stk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#view-stock button.btn.stk-orange { background: var(--amber); }
#view-stock button.btn.stk-orange:hover { background: #b06c22; }

#view-stock .stk-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
#view-stock .stk-kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; text-align: left; cursor: pointer; font-family: var(--sans); color: var(--ink);
}
#view-stock .stk-kpi:hover { border-color: var(--teal); }
#view-stock .stk-kpi.on { outline: 2px solid var(--teal-dark); outline-offset: -1px; background: var(--teal-soft); }
#view-stock .stk-kpi .k { display: block; font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
#view-stock .stk-kpi .v { display: block; font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
#view-stock .stk-kpi .h { display: block; font-size: 12.5px; color: var(--ink-soft); }
#view-stock .stk-kpi.warn .v { color: var(--stk-warn); }
#view-stock .stk-kpi.crit .v { color: var(--red); }

#view-stock .stk-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
#view-stock .stk-tab {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 8px 14px; font-weight: 600;
  font-size: 14px; cursor: pointer; font-family: var(--sans); color: var(--ink); min-height: 40px;
}
#view-stock .stk-tab.on { background: var(--teal-dark); color: #fff; border-color: var(--teal-dark); }
#view-stock .stk-tab .b { background: var(--red); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 6px; margin-left: 4px; }

#view-stock .stk-filters { display: flex; flex-direction: column; gap: 10px; }
#view-stock .stk-frow { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
#view-stock .stk-search { flex: 1; min-width: 200px; }

#view-stock table.stk-table { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; min-width: 720px; }
#view-stock .stk-tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
#view-stock .stk-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f7f9f8; white-space: nowrap;
}
#view-stock .stk-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
#view-stock .stk-table tr:last-child td { border-bottom: 0; }
#view-stock .stk-table tr.zone td {
  background: #f3f6f4; font-size: 12px; font-weight: 700; color: var(--teal-dark); text-transform: uppercase; letter-spacing: .06em; padding: 7px 14px;
}
#view-stock .stk-table tr.p:hover td { background: #f8faf9; }
#view-stock .stk-table tr.p.crit td:first-child { box-shadow: inset 3px 0 0 var(--red); }
#view-stock .stk-table tr.p.warn td:first-child { box-shadow: inset 3px 0 0 var(--stk-warn); }
#view-stock .stk-name { font-weight: 600; cursor: pointer; }
#view-stock .stk-name:hover { text-decoration: underline; }
#view-stock .stk-meta { font-size: 12.5px; color: var(--ink-soft); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#view-stock .stk-alg { font-size: 10.5px; font-weight: 700; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; text-transform: uppercase; }
#view-stock .stk-bar { width: 140px; height: 7px; border-radius: 4px; background: #e5eae7; position: relative; }
#view-stock .stk-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--stk-ok); }
#view-stock .stk-bar i.w { background: var(--stk-warn); }
#view-stock .stk-bar i.c { background: var(--red); }
#view-stock .stk-bar s { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #33423b; }
#view-stock .stk-bl { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
#view-stock .stk-q { font-weight: 600; font-size: 16px; text-align: right; white-space: nowrap; }
#view-stock .stk-q small { font-weight: 400; color: var(--ink-soft); font-size: 12.5px; }
.stk-pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.stk-pill.ok { background: #e1f2e7; color: #2e7d4f; }
.stk-pill.w { background: #fcefd6; color: #a8660f; }
.stk-pill.c { background: var(--red-soft); color: var(--red); }
.stk-pill.n { background: #eef1ef; color: var(--ink-soft); }
.stk-pill.out { background: var(--blue-soft); color: var(--blue); }
#view-stock .stk-act { display: flex; gap: 6px; justify-content: flex-end; }
#view-stock .stk-act button {
  width: 44px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 6px;
  font-size: 20px; font-weight: 700; cursor: pointer; color: var(--ink); font-family: var(--sans);
}
#view-stock .stk-act button:hover { border-color: var(--teal-dark); color: var(--teal-dark); }
#view-stock .stk-empty { padding: 28px; text-align: center; color: var(--ink-soft); }

#view-stock .stk-shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; align-items: start; }
#view-stock .stk-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
#view-stock .stk-card h3 { margin: 0; padding: 11px 14px; font-size: 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
#view-stock .stk-card h3 span { font-weight: 400; color: var(--ink-soft); font-size: 13px; }
#view-stock .stk-sr { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
#view-stock .stk-card h3 + .stk-sr { border-top: 0; }
#view-stock .stk-sr .grow { flex: 1; min-width: 0; }

/* Fenêtres (hors de #view-stock) */
dialog.stk-dlg { border: 0; border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--ink); font-family: var(--sans); }
dialog.stk-dlg::backdrop { background: rgba(20,35,30,.45); }
.stk-dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); margin: 0; }
.stk-dh { background: var(--teal-dark); color: #fff; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stk-dh h2 { margin: 0; font-size: 18px; }
.stk-dh p { margin: 2px 0 0; font-size: 13px; opacity: .85; }
.stk-dh .x { background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; min-height: 0; }
.stk-db { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.stk-df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.stk-seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.stk-seg button { border: 0; border-right: 1px solid var(--line); background: #fff; padding: 10px; font-weight: 600; cursor: pointer; font-family: var(--sans); min-height: 44px; color: var(--ink); }
.stk-seg button:last-child { border-right: 0; }
.stk-seg button.on { background: var(--teal-dark); color: #fff; }
.stk-qty { display: flex; gap: 8px; }
.stk-qty button { width: 52px; border: 1px solid var(--line); background: #fff; border-radius: 6px; font-size: 22px; cursor: pointer; }
.stk-qty input { flex: 1; min-width: 0; text-align: center; font-size: 24px; font-weight: 600; }
.stk-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.stk-presets button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; cursor: pointer; font-family: var(--sans); font-size: 14px; }
.stk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stk-grid2 > div { display: flex; flex-direction: column; min-width: 0; }
.stk-grid2 input, .stk-grid2 select, .stk-db > div > input { width: 100%; }
@media (max-width: 520px) { .stk-grid2 { grid-template-columns: 1fr; } }
.stk-prev { font-size: 14px; }
.stk-prev b { font-variant-numeric: tabular-nums; }
.stk-prev .w { color: #a8660f; } .stk-prev .c { color: var(--red); }
.stk-algs { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.stk-algs label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); margin: 0; cursor: pointer; }
.stk-algs input { min-height: 0; width: 16px; height: 16px; }
.stk-fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 0; }
.stk-fieldset legend { font-size: 0.8rem; color: var(--ink-soft); padding: 0 4px; }
.stk-hist { border: 1px solid var(--line); border-radius: 6px; max-height: 190px; overflow: auto; }
.stk-hist .r { display: grid; grid-template-columns: 92px 84px minmax(0, 1fr) auto; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--line); font-size: 13.5px; align-items: center; }
.stk-hist .r:first-child { border-top: 0; }
.stk-hist .r time, .stk-hist .r .who { color: var(--ink-soft); font-size: 12.5px; }
.stk-hist .r .d { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.stk-mr-auto { margin-right: auto; }

@media (max-width: 900px) { #view-stock .stk-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Sélection multiple */
#view-stock .stk-ck { width: 44px; text-align: center; padding-left: 10px; padding-right: 0; }
#view-stock .stk-ck input { width: 20px; height: 20px; min-height: 0; margin: 0; cursor: pointer; accent-color: var(--teal-dark); vertical-align: middle; }
#view-stock .stk-table tr.p.sel td { background: var(--teal-soft); }
#view-stock .stk-selbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
  padding: 10px 14px; border: 1px solid var(--teal); background: var(--teal-soft); border-radius: var(--radius);
  position: sticky; top: 0; z-index: 5;
}
#view-stock .stk-selbar span { font-weight: 700; color: var(--teal-dark); margin-right: auto; }
.stk-delliste { margin: 0; padding-left: 20px; max-height: 260px; overflow: auto; columns: 2; column-gap: 24px; }
.stk-delliste li { break-inside: avoid; padding: 2px 0; }
@media (max-width: 520px) { .stk-delliste { columns: 1; } }
