/* Phase 2 Bug 001. Paint the existing KeyStock button without changing its box. */
#keyStockNav {
  display:flex; align-items:center; justify-content:space-between;
  position:relative; isolation:isolate; overflow:hidden;
  color:#fff; font-weight:700;
  background:linear-gradient(110deg,#075469,#063e5a);
  box-shadow:inset 0 0 0 2px #16eff7,inset 0 0 14px #05e9ff3d,0 0 10px #05e9ff58;
}
#keyStockNav::before {
  content:""; position:absolute; z-index:-1; right:-16px; bottom:-32px;
  width:68px; height:68px; border:1px solid #21e8f966; border-radius:50%;
  box-shadow:0 0 16px #05e9ff3d;
}
#keyStockNav:hover,#keyStockNav.active {background:linear-gradient(110deg,#086378,#074663)}
#keyStockNav[hidden] {display:none}
#keyStockNav svg,#keyStock .stock-tabs svg {
  width:1.15em;height:1.15em;flex:none;fill:none;stroke:currentColor;stroke-width:1.65;
  stroke-linecap:round;stroke-linejoin:round;
}
#keyStockNav svg {position:absolute;right:14px;top:50%;transform:translateY(-50%);width:21px;height:21px}
@media (min-width:621px) and (max-width:1000px){#keyStockNav svg{right:8px;width:16px;height:16px}}
@media (max-width:620px){#keyStockNav svg{position:static;transform:none;margin-left:6px}}

#keyStock .stock-workspace {
  display:grid;grid-template-columns:minmax(155px,235px) minmax(0,1fr);align-items:start;gap:16px;
}
#keyStock .stock-tabs {
  display:grid;gap:5px;padding:9px;background:#fff;border:1px solid #e2e8f0;border-radius:13px;
}
#keyStock .stock-tabs button {
  display:flex;align-items:center;gap:9px;width:100%;min-height:43px;padding:9px 10px;
  border:1px solid transparent;border-radius:8px;background:var(--stock-tab-color);color:#111;
  text-align:left;
}
#keyStock .stock-tabs button[aria-current="page"] {border-color:#475569;font-weight:700}
#keyStock .stock-tabs [data-tab="check"] {--stock-tab-color:#ffe5e5}
#keyStock .stock-tabs [data-tab="missing"] {--stock-tab-color:#ffead7}
#keyStock .stock-tabs [data-tab="reservations"] {--stock-tab-color:#fff3cc}
#keyStock .stock-tabs [data-tab="movement"] {--stock-tab-color:#e3f2da}
#keyStock .stock-tabs [data-tab="history"] {--stock-tab-color:#ddf0f5}
#keyStock .stock-tabs [data-tab="receive"] {--stock-tab-color:#e5e8ff}
#keyStock .stock-tabs [data-tab="dropdowns"] {--stock-tab-color:#eee2f5}
#keyStock .stock-management-label {border-top:1px solid #e2e8f0;margin-top:6px;padding:9px 0 2px;font-size:.75rem;text-transform:uppercase}
#keyStock #stockUtilities {margin-bottom:12px}
#keyStock #stockUtilities:not([open]) summary {margin-bottom:0}
#keyStock .stock-phase2-table th,#keyStock .stock-phase2-table td {text-align:center;vertical-align:middle}
#keyStock .stock-phase2-table td {background:#fff}
#keyStock .stock-phase2-table th input {margin-top:6px;min-width:110px}
#keyStock .stock-detail-head {display:flex;align-items:center;gap:12px;margin-bottom:14px}
#keyStock .stock-detail-head h2 {margin:0}
#keyStock .stock-detail-metrics {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:12px 0}
#keyStock .stock-history-metrics {grid-template-columns:repeat(3,minmax(0,1fr))}
#keyStock .stock-detail-metrics>div {display:grid;gap:8px;text-align:center;border:1px solid #cbd5e1;border-radius:8px;padding:10px 4px}
#keyStock .stock-detail-metrics .stock-link {text-align:center;color:#1763a2}
#keyStock .stock-normal-row {display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:10px 0}
#keyStock .stock-normal-row span {border:1px solid #cbd5e1;border-radius:6px;padding:5px 8px}
#keyStock .stock-sr {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
#keyStock .stock-row-actions {display:flex;justify-content:center;gap:5px}
#keyStock .stock-row-action {min-width:30px;min-height:30px;border:1px solid #bfc9d3;border-radius:6px;font-weight:700}
#keyStock .stock-row-action.adjust {background:#d7f3d7;color:#155b31}
#keyStock .stock-row-action.reserve {background:#fff1b8;color:#6b4c00}
#keyStock .stock-row-action.issue {background:#ffe1df;color:#892c2c}
#keyStock .stock-reservation,#keyStock #stockMovementFormPanel,#keyStock #stockReceiveForm>details {margin:10px 0}
#keyStock #stockReceiptConfig fieldset {margin:8px 0;border:1px solid #dbe4ee;border-radius:8px}
#keyStock #stockReceiptRows :is(input,select) {min-width:84px}
#keyStock #stockReceiptRows [name="model"] {min-width:145px}
#keyStock details.stock-movement-detail {padding:0;border:0}
#keyStock .stock-movement-detail summary {margin:0}
@media (max-width:760px){#keyStock .stock-workspace{grid-template-columns:minmax(0,1fr)}}
@media (max-width:480px){#keyStock .stock-detail-metrics{font-size:.8rem;gap:4px}}
#keyStock .stock-form{display:grid;grid-template-columns:repeat(3,minmax(160px,1fr));gap:16px}#keyStock .stock-wide{grid-column:1/-1}#keyStock .stock-tools{display:flex;gap:12px;align-items:end;flex-wrap:wrap;margin:16px 0}#keyStock .stock-tools>label{min-width:180px;flex:1}#keyStock label{display:block}#keyStock label input,#keyStock label select{display:block;margin-top:6px;width:100%;box-sizing:border-box}#keyStock input[type=checkbox]{display:inline;width:auto;margin-right:6px}#keyStock .stock-message{white-space:pre-wrap;padding:12px 16px;border-radius:10px;background:#edf5fc;margin-bottom:16px}#keyStock .stock-message.error{background:#fff0ee;color:#922}#keyStock .stock-scroll{overflow:auto}#keyStock table{border-collapse:collapse;width:100%}#keyStock th,#keyStock td{text-align:left;padding:12px;border-bottom:1px solid #e3eaf3;vertical-align:top}#keyStock th{background:#eef3f8}#keyStock .stock-link{background:none;border:0;color:#17365d;cursor:pointer;text-align:left;font:inherit;font-weight:700;padding:0}#keyStock .stock-options{display:grid;gap:10px}#keyStock .stock-option{display:grid;grid-template-columns:minmax(150px,1fr) auto auto auto;align-items:center;gap:8px}#keyStock details{padding:14px;border:1px solid #dbe4ee;border-radius:10px}#keyStock summary{cursor:pointer;font-weight:700;margin-bottom:12px}#keyStock .stock-badge{display:inline-block;padding:4px 8px;background:#edf5fc;border-radius:6px;font-size:12px}#keyStock .stock-targets{max-height:240px;overflow:auto;padding:10px;border:1px solid #dbe4ee}#keyStock .stock-targets label{margin:7px}#keyStock small{display:block;color:#64748b;margin-top:5px}#keyStock .stock-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}#keyStock .stock-summary{display:flex;gap:20px;flex-wrap:wrap;margin:12px 0;color:#17365d}@media(max-width:800px){#keyStock .stock-form{grid-template-columns:1fr}#keyStock .stock-option{grid-template-columns:1fr auto auto}#keyStock .stock-option label{grid-column:1/-1}}

#keyStock .stock-heading,#keyStock #stockEditActions,#keyStock .stock-ref {
  display:flex; gap:8px; align-items:center;
}
#keyStock .stock-heading {justify-content:space-between; flex-wrap:wrap; margin-bottom:16px}
#keyStock .stock-heading h1 {margin:0}
#keyStock [hidden] {display:none!important}
#keyStock .stock-ref {align-items:end}
#keyStock .stock-ref label {flex:1; min-width:0}
#keyStock .stock-ref-list li,#keyStock .stock-ref-list>div {margin:8px 0}
#keyStock .stock-danger {background:#b42318;color:#fff}
#keyStock .stock-copy {margin-top:12px}
#keyStock .stock-metrics-note {color:#475569;font-size:.9rem}
#keyStock .stock-model {border-top:1px solid #e3eaf3}
#keyStock .stock-model-row {
  display:grid;grid-template-columns:minmax(140px,2fr) repeat(5,minmax(75px,1fr)) minmax(120px,auto);
  gap:12px;align-items:center;padding:12px 4px;
}
#keyStock .stock-model-row small {margin:0 0 4px}
#keyStock .stock-config-table details {margin-bottom:6px;padding:8px}
#keyStock .stock-config-table summary {margin-bottom:0}
#keyStock .stock-config-table dl {display:grid;grid-template-columns:auto 1fr;gap:6px}
#keyStock .stock-config-table dd {margin:0}
@media(max-width:1050px){
  #keyStock .stock-model-row {grid-template-columns:repeat(3,minmax(0,1fr))}
  #keyStock .stock-model-row>div:first-child {grid-column:span 2}
}
@media(max-width:560px){
  #keyStock .stock-model-row {grid-template-columns:repeat(2,minmax(0,1fr))}
  #keyStock .stock-config-table {min-width:430px}
}
#keyStock .stock-browser-heading{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:18px}
#keyStock .stock-browser-heading h2{margin:0 0 6px}
#keyStock .stock-browser-heading p{margin:0;color:#667085}
#keyStock .stock-browser-heading>span{background:#eef2f6;border-radius:20px;padding:6px 12px;white-space:nowrap;font-size:13px}
#keyStock .stock-browser-scroll{overflow-x:auto;overscroll-behavior-x:contain}
#keyStock .stock-browser{display:grid;grid-template-columns:minmax(150px,.8fr) minmax(180px,1fr) minmax(200px,1.1fr) minmax(260px,1.3fr);gap:12px;min-width:838px;align-items:stretch}
#keyStock .stock-browser>section{background:#f5f6f8;border-radius:14px;padding:14px;min-width:0;max-height:620px;overflow-y:auto;min-height:470px}
#keyStock .stock-browser h3{margin:4px 0 18px;font-size:17px;line-height:1.4}
#keyStock .stock-browser-row{display:flex;justify-content:space-between;align-items:center;gap:12px;text-align:left;width:100%;border:1px solid transparent;border-radius:10px;background:#fff;color:#20242a;padding:16px 12px;margin-bottom:9px;min-height:58px;overflow-wrap:anywhere;cursor:pointer;font:inherit}
#keyStock .stock-browser-row[aria-pressed=true]{background:#dfe8f5;border-color:#c7d6eb;font-weight:700}
#keyStock .stock-browser-row[aria-pressed=true]>span:last-child{color:#2465c6}
#keyStock .stock-browser-row small{display:block;font-weight:400;color:#667085}
#keyStock .stock-browser :focus-visible{outline:3px solid #2a70d6;outline-offset:2px}
#keyStock .stock-browser .stock-option-add{width:100%;border:1px solid #cdd4df;border-radius:22px}
#keyStock .stock-browser button:disabled{opacity:.5;cursor:default}
#keyStock .stock-browser-note{font-size:13px;color:#667085;line-height:1.6}
#keyStock .stock-browser-applies{color:#167342;font-size:14px;line-height:1.6}
#keyStock .stock-browser hr{border:0;border-top:1px solid #e0e5ed;margin:24px 0}
#keyStock .stock-browser form label{display:grid;gap:8px}
#keyStock .stock-browser form input{width:100%;box-sizing:border-box}
#keyStock .stock-browser li{margin-bottom:6px}
/* V1.04: all editing remains inside the fourth Finder column. */
.stock-link-record{margin:12px 0;padding:12px;border:1px solid #d7e1ed;border-radius:10px;background:white}
.stock-link-option{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin:10px 0}
.stock-link-option span{flex:1;min-width:100px}
#stockLinkForm label{display:block;margin:12px 0}
#stockLinkForm input,#stockLinkForm select{display:block;width:100%;box-sizing:border-box;margin-top:6px}
.stock-link-record summary{cursor:pointer;font-weight:600}

#keyStock [data-detail-option][aria-pressed="true"]{background:#175b9b;color:white}
#keyStock [data-detail-option]{font:inherit;min-height:38px;padding:8px 14px;border-radius:8px}
#keyStock .stock-inline-fields{--stock-label-width:14rem;display:grid;gap:10px;margin-block:8px}
#keyStock .stock-inline-fields label{
  display:grid;grid-template-columns:var(--stock-label-width) minmax(0,1fr);align-items:center;gap:12px;margin:0
}
#keyStock .stock-inline-fields label :is(input,select,textarea){width:100%;min-width:0;box-sizing:border-box;margin:0;min-height:40px}
#keyStock .stock-inline-fields label input[type=checkbox]{width:auto;min-height:0;justify-self:start}
#keyStock .stock-inline-fields label input[readonly]{background:#f3f6fa}
#keyStock .stock-inline-footer{padding-inline-start:calc(var(--stock-label-width) + 12px)}
#keyStock #stockBatchCorrection>.stock-inline-footer{padding-inline-start:calc(var(--stock-label-width) + 27px)}
#keyStock .stock-inline-footer .btn{margin-inline-end:6px}
#keyStock .stock-inline-footer:empty{display:none}
#keyStock .stock-component-availability{margin-top:12px}
#keyStock #stockContent [aria-label="Stock Check results"] col:first-child{width:40%}
#keyStock .stock-configuration-table {width:100%;table-layout:fixed;min-width:62rem}
#keyStock .stock-configuration-table col:nth-child(1){width:13rem}
#keyStock .stock-configuration-table col:nth-child(3){width:6.5rem}
#keyStock .stock-configuration-table col:nth-child(4),
#keyStock .stock-configuration-table col:nth-child(5){width:4.75rem}
#keyStock .stock-configuration-table col:nth-child(6){width:8rem}
#keyStock .stock-configuration-table col:nth-child(7){width:5.5rem}
#keyStock .stock-configuration-table col:last-child{width:12rem}
#keyStock .stock-configuration-table.has-cannibalise{min-width:69rem}
#keyStock .stock-configuration-table.has-cannibalise col:last-child{width:19rem}
#keyStock .stock-configuration-table > tbody[hidden]{display:none}
#keyStock .stock-configuration-table :is(th,td){text-align:center;vertical-align:middle}
#keyStock .stock-configuration-table :is(th,td):nth-child(-n+2){text-align:left}
#keyStock .stock-configuration-table th{white-space:nowrap}
#keyStock .stock-configuration-table .stock-configuration-summary th{background:white;white-space:normal;overflow-wrap:anywhere}
#keyStock .stock-configuration-table td:nth-child(2){overflow-wrap:anywhere}
#keyStock .stock-configuration-table .stock-row-actions{flex-wrap:nowrap;align-items:center;gap:4px;white-space:nowrap}
#keyStock .stock-configuration-table .stock-row-action:not([data-row-action="cannibalise"]){
  display:inline-flex;align-items:center;justify-content:center;flex:0 0 30px;width:30px;height:30px;padding:0;box-sizing:border-box
}
#keyStock .stock-row-action.delete-batch{background:#A52019;color:#fff}
#keyStock .stock-configuration-table [data-edit-position]{background:#bcbcbc;color:#222}
#keyStock #stockContent .stock-phase2-table :is(th,td){font-variant-numeric:tabular-nums}
#keyStock #stockContent [data-stock-left~="1"]> :is(thead,tbody)>tr> :first-child,
#keyStock #stockContent [data-stock-left~="2"]> :is(thead,tbody)>tr> :nth-child(2),
#keyStock #stockContent [data-stock-left~="3"]> :is(thead,tbody)>tr> :nth-child(3),
#keyStock #stockContent [data-stock-left~="5"]> :is(thead,tbody)>tr> :nth-child(5),
#keyStock #stockContent [data-stock-left~="6"]> :is(thead,tbody)>tr> :nth-child(6),
#keyStock #stockContent [data-stock-left~="8"]> :is(thead,tbody)>tr> :nth-child(8){text-align:left}
@media(max-width:800px){
  #keyStock .stock-inline-fields{--stock-label-width:8rem}
  #keyStock #stockContent [aria-label="Stock Check results"]{min-width:33rem}
}
