.order-page {container-type:inline-size;--order-soft:#f8f4f1;--order-brown:#644b36;--order-warning:#774b21;min-width:0}
.order-page .pagetop {align-items:center}
.order-page .pagetop h1 {margin:0;font-size:clamp(1.8rem,3vw,2.6rem);font-weight:500}
.order-identity {margin:9px 0 24px;color:var(--muted);font-size:0.96rem}
.order-layout {display:grid;grid-template-columns:minmax(0,1fr) minmax(235px,31%);gap:18px;align-items:start}
.order-lines {display:grid;gap:16px;min-width:0}
.order-line,.order-sheet,.order-review,.orders-history,.history-filter,.order-total {background:#fff;border:1px solid var(--line);border-radius:5px}
.order-item-head {display:grid;grid-template-columns:75px minmax(0,1fr) auto;align-items:center;gap:16px;padding:18px}
.order-photo {display:grid;place-items:center;position:relative;overflow:hidden;width:75px;aspect-ratio:4/5;background:#f2eeea;border-radius:3px}
.order-photo img {display:block;width:100%;height:100%;object-fit:cover}
.order-photo span {font-size:0.76rem;text-align:center;color:var(--muted);line-height:1.3}
.order-photo [hidden] {display:none!important}
.order-item-title {min-width:0}
.order-item-title h2 {font:650 1.12rem/1.28 Raleway,Arial,sans-serif;margin:4px 0}
.order-item-title>small,.editor-product span,.part-meta,.order-component small,.money-row>span,.order-sheet dt,.order-history-row small,.history-labels {font-size:0.85rem;line-height:1.4;color:var(--muted)}
.order-item-title>span {font-size:0.94rem}
.order-cost {white-space:nowrap;font-size:1.05rem}
.order-components {border-top:1px solid var(--line);margin:0 18px}
.order-component {display:grid;grid-template-columns:minmax(0,0.95fr) minmax(0,1fr);align-items:center;gap:12px;padding:13px 0;border-bottom:1px solid #ece8e4}
.order-component strong,.order-component small {display:block}
.order-component small {margin-top:2px}
.order-component:last-child {border-bottom:0}
.chosen-sizes {display:flex;flex-wrap:wrap;gap:5px}
.chosen-sizes span {background:var(--order-soft);padding:3px 9px;border-radius:4px;font-size:0.92rem}
.fix-part,.review-link,.remove-btn {font:inherit;line-height:1.35;text-align:left}
.fix-part,.review-link {font-size:0.93rem;color:var(--wine);padding:4px 0;font-weight:650;text-decoration:underline;text-underline-offset:3px}
.fix-part {min-height:36px}
.cart-warn-text {color:var(--order-warning)!important}
.order-item-actions {display:flex;align-items:center;gap:16px;flex-wrap:wrap;background:#fcfbf9;padding:11px 18px;border-top:1px solid var(--line)}
.remove-btn {font-size:0.9rem;color:var(--muted);padding:7px 3px}
.remove-btn:hover,.order-back:hover {color:var(--wine)}
.order-review {padding:20px;position:sticky;top:12px}
.order-review h2,.order-sheet h2 {font-size:1.15rem;margin:0 0 12px}
.money-row,.order-total {display:flex;justify-content:space-between;align-items:baseline;gap:10px;flex-wrap:wrap}
.money-row strong,.order-total strong {font:600 1.45rem/1.2 Raleway,Arial,sans-serif}
.review-state,.cart-conflict {padding:13px 14px;border-radius:3px;margin:17px 0;line-height:1.38}
.review-state b,.review-state span {display:block}
.review-state b {margin-bottom:4px;font-size:0.95rem}
.review-state span {font-size:0.9rem}
.review-state.incomplete,.cart-conflict {background:#fbf3e9;color:#694524;border-left:3px solid #ae7444}
.review-state.complete {background:#eff6f1;color:#295740;border-left:3px solid #579174}
.cart-conflict p {margin:4px 0 8px}
.order-review .field textarea {resize:vertical;width:100%;min-height:65px}
.order-review .send-order,.order-review .save-order {width:100%;margin-top:10px;min-height:43px}
.order-review .continue-order{width:100%;margin-top:12px}
.added-product{display:flex;align-items:center;gap:16px}
.added-product .order-photo{flex:0 0 64px}
.added-product strong,.added-product small,.added-product span{display:block}
.added-product small{color:var(--muted)}
.added-product strong{margin:4px 0}
.purchase-next>a,.purchase-next>button{flex:1 1 auto;text-align:center}
@media(min-width:761px){.order-page .continue-top{display:none}}
.order-review .send-order:disabled {background:#ebe7e6;color:#645d60;border:1px solid #e0d9db;opacity:1;cursor:not-allowed}
.save-status {display:block;min-height:1.25em;margin-top:7px;font-size:0.83rem;color:var(--muted)}
.size-editor {display:grid;gap:16px}
.editor-product {display:flex;align-items:center;gap:14px}
.editor-product .order-photo {width:54px}
.editor-product>div:last-child>strong,.editor-product>div:last-child>span {display:block}
.editor-product strong {font-size:1.1rem;margin-top:2px}
.kit-count {display:flex;align-items:center;justify-content:space-between;gap:16px;border-top:1px solid var(--line);padding-top:14px}
.kit-count label {font-weight:600}
.kit-count input {width:90px;min-height:45px;text-align:center;border:1px solid #aaa5a5;border-radius:4px}
[data-size-parts] {display:grid;gap:16px;min-width:0}
.part-picker {min-width:0;margin:0;padding:8px 16px 13px;border:1px solid #d8d0ce;border-radius:4px}
.part-picker legend {padding:0 5px;margin-left:-5px;max-width:100%;font-size:1.08rem;font-weight:650}
.part-meta {margin:0 0 8px}
.size-instruction {font-size:0.97rem;margin:0 0 9px}
.size-options,.size-matrix {display:grid;grid-template-columns:repeat(auto-fit,minmax(60px,1fr));gap:8px}
.size-option {position:relative;min-width:0;cursor:pointer}
.size-option input {position:absolute;margin:0;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}
.size-option span {display:grid;place-items:center;min-height:46px;padding:6px 4px;border:1px solid #aaa5a5;border-radius:4px;font-weight:600;color:var(--ink);line-height:1.25;overflow-wrap:anywhere}
.size-option input:checked+span {background:var(--wine);color:white;border-color:var(--wine)}
.size-option input:focus-visible+span {outline:3px solid #b54a70;outline-offset:2px}
.size-quantity {display:grid;align-content:start;justify-items:stretch;border-radius:4px;overflow:hidden;border:1px solid #b5aca9}
.size-quantity span {padding:5px 2px;text-align:center;font-weight:650;background:#f5f1ed;font-size:1rem}
.size-quantity input {width:100%;min-width:0;min-height:44px;text-align:center;border:0;border-top:1px solid #d5ccc8;font-size:1rem}
.size-quantity:focus-within {outline:2px solid var(--wine);outline-offset:1px}
.part-feedback {margin:10px 0 0;font-size:0.93rem;font-weight:600}
.part-feedback.incomplete {color:#785021}
.part-feedback.complete {color:#2e6749}
.editor-bottom {border-top:1px solid var(--line);padding-top:12px}
.editor-bottom>div:first-child {display:flex;align-items:baseline;justify-content:space-between;gap:12px}
.editor-bottom>div:first-child strong {font-size:1.22rem}
.editor-bottom p {font-size:0.93rem;margin:7px 0}
.editor-bottom .btn {min-width:120px;margin-top:7px}
.order-sheet {padding:20px;margin:18px 0}
.order-sheet dl {display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:14px;margin:15px 0 0}
.order-sheet dd {margin:3px 0 0}
.order-comment {border-top:1px solid var(--line);padding-top:14px;margin-top:14px}
.order-comment p {margin:3px 0;white-space:pre-wrap}
.order-back {display:inline-block;color:var(--wine);margin:0 0 12px;text-decoration:underline;text-underline-offset:3px}
.order-total {margin:15px 0;padding:18px}
.history-filter {display:flex;align-items:end;flex-wrap:wrap;gap:10px;padding:14px;margin:18px 0}
.history-filter .field {min-width:110px;flex:1}
.history-filter .field+.field {margin:0}
.history-filter .error:not(:empty) {flex:0 0 100%}
.history-filter-actions {display:flex;align-items:center;gap:5px}
.history-labels,.order-history-row {display:grid;grid-template-columns:minmax(110px,1.5fr) minmax(76px,.85fr) minmax(76px,.85fr) minmax(90px,1fr) minmax(75px,.78fr);align-items:center;gap:12px;padding:12px 15px}
.history-labels {background:#f4f0ec;font-weight:650}
.history-labels span:last-child,.order-history-row>div:last-child {text-align:right}
.order-history-row+.order-history-row {border-top:1px solid var(--line)}
.order-history-row:hover {background:#faf6f4}
.order-history-row>div {min-width:0}
.order-history-row>div:first-child>strong {color:var(--wine)}
.order-history-row small {display:none}
.order-history-row>div:first-child>small {display:block}
.order-status {display:inline-block;border-radius:4px;padding:3px 8px;font-size:0.85rem;background:#f2ece3;color:#6b502d}
.order-status.complete {background:#eaf3ed;color:#2e6044}
@container (max-width:860px) {
  .order-layout {grid-template-columns:1fr}
  .order-review {position:static}
}
@container (max-width:640px) {
  .order-page .pagetop {align-items:start}
  .order-item-head {grid-template-columns:60px minmax(0,1fr);padding:14px;gap:8px 12px}
  .order-photo {width:60px}
  .order-item-head .order-photo {grid-row:span 2}
  .order-cost {grid-column:2}
  .order-components {margin:0 14px}
  .order-component {grid-template-columns:1fr;gap:5px}
  .order-item-actions {padding:9px 14px}
  .history-labels {display:none}
  .order-history-row {grid-template-columns:1fr 1fr;gap:6px 12px}
  .order-history-row>div:first-child {grid-column:1/-1}
  .order-history-row>div:nth-child(2)>small,.order-history-row>div:nth-child(3)>small {display:block}
}
@media (max-width:480px) {
  .size-editor {gap:12px}
  .part-picker {padding:6px 11px 12px}
  .size-options,.size-matrix {grid-template-columns:repeat(3,minmax(0,1fr))}
  .editor-bottom .btn {width:100%}
  .order-review,.order-sheet {padding:16px}
}

/* Size combinations and the independent size matrix share the same checkout. */
dialog.large[open]:has(.purchase-picker){display:flex;flex-direction:column;overflow:hidden;width:min(690px,calc(100% - 24px))}
dialog:has(.purchase-picker) .dialog-top{flex:none;padding:8px 18px}
dialog:has(.purchase-picker) #dialog-content{display:flex;flex-direction:column;min-height:0;padding:0}
.purchase-picker{display:flex;flex-direction:column;min-height:0;gap:0}
.picker-summary,.purchase-picker .picker-foot{flex:none;padding:10px 18px;background:white}
.picker-summary{border-bottom:1px solid var(--line);position:relative;z-index:1}
.picker-summary-row{display:flex;align-items:center;gap:clamp(10px,2.4vw,27px)}
.picker-summary-row>.picker-product{min-width:0;margin-right:auto}
.picker-stat{display:grid;align-content:center;line-height:1.25}
.picker-stat small,.picker-product small,.picker-contents summary span{color:var(--muted)}
.picker-stat strong{font-size:1.12rem;font-variant-numeric:tabular-nums}
.picker-contents{margin-top:7px;position:relative}
.picker-contents summary{display:flex;align-items:baseline;gap:8px;cursor:pointer;font-size:.86rem;font-weight:600;white-space:nowrap}
.picker-contents summary::before{content:'▸';color:var(--wine)}
.picker-contents[open] summary::before{content:'▾'}
.picker-contents summary span{min-width:0;overflow:hidden;text-overflow:ellipsis;font-weight:400}
.picker-contents>div{position:absolute;inset:auto 0;max-height:30dvh;overflow:auto;display:grid;padding:4px;background:white;border:1px solid var(--line);box-shadow:0 6px 16px #28181922}
.picker-contents button{text-align:left;padding:9px}
.picker-contents button:hover,.picker-contents button:focus-visible{background:var(--order-soft,#f8f4f1)}
.picker-scroll{min-height:0;padding:12px 18px;overflow:auto;overscroll-behavior:contain}
.picker-scroll [data-entry-mode]:not(:empty){margin-bottom:12px}
.picker-product{display:flex;align-items:center;gap:12px}
.picker-product img{width:45px;height:53px;object-fit:cover;border-radius:4px}
.picker-product>.kit-photos{width:45px;height:53px;flex-shrink:0;border-radius:4px}
.picker-product>.kit-photos img{width:100%;height:100%;border-radius:0}
.picker-product div{display:grid;gap:2px}
.picker-product small{color:var(--muted)}
.mode-review{margin:10px 0 0;padding:12px;background:#f6f1eb;border-radius:4px}
.picker-switch-note{color:var(--muted);font-size:.875rem;margin:6px 0 0}
.picker-instruction{margin:10px 0 0}
.picker-instruction:first-child{margin-top:0}
.picker-body{display:grid;gap:12px}
.picker-row{display:flex;align-items:flex-end;gap:12px;flex-wrap:wrap;padding:13px;border:1px solid var(--line);border-radius:5px;background:#fcfaf9}
.picker-size,.picker-quantity{display:grid;gap:5px;font-size:.88rem;font-weight:600;min-width:0}
.picker-size{flex:1 1 124px}
.picker-size small{color:var(--muted);font-weight:400}
.picker-size select{width:100%;min-height:42px;padding:5px 7px;font:inherit;color:var(--ink);background:white;border:1px solid #afa6a5;border-radius:4px}
.step-controls{display:inline-flex;align-items:stretch;width:max-content;max-width:100%;border:1px solid #afa6a5;background:white;border-radius:4px;overflow:hidden}
.step-controls input,.step-controls button{border:0;background:white;min-height:42px;text-align:center;padding:0 4px;color:var(--ink)}
.step-controls input{font-size:1rem;width:54px;-moz-appearance:textfield;appearance:textfield}
.step-controls input::-webkit-inner-spin-button,.step-controls input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.step-controls button{width:35px;font-size:1.15rem;color:var(--wine)}
.step-controls :focus-visible{outline:2px solid var(--wine);outline-offset:-3px}
.picker-remove{min-height:40px;color:var(--wine);text-decoration:underline}
.add-picker-row{justify-self:start}
.picker-foot{border-top:1px solid var(--line);padding:12px 0 0;background:white}
.picker-message{margin:6px 0;color:#7a4e1b;font-size:.93rem}
.picker-message:empty,.purchase-picker [data-entry-mode]:empty{display:none}
.picker-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px}
.picker-actions .save-status{margin:0}
.picker-actions .btn{min-width:145px}
.purchase-picker .btn:disabled{background:#e8e4e3;color:#665d5d;opacity:1;cursor:default}
.undo-lines{display:grid;gap:5px;margin:12px 0}.undo-lines>div{display:flex;align-items:center;justify-content:space-between;gap:8px;background:#f4eeeb;padding:10px 12px}
.order-combination{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--line)}
.order-combination:last-child{border:0}.order-combination div{display:flex;gap:5px 14px;flex-wrap:wrap}.order-combination strong{white-space:nowrap}.order-combination b{padding:2px 6px;background:#f3edeb;border-radius:3px}
@media(max-width:550px){.picker-row{gap:8px}.picker-size{flex:1 1 42%}.picker-row .picker-quantity{flex:1 1 auto}.picker-foot{position:sticky;bottom:-1px;z-index:1;padding-bottom:5px}.purchase-picker .picker-actions .btn{min-width:110px}.picker-actions .save-status{font-size:.77rem}.order-combination div{display:grid}.step-controls button{width:40px}}

.history-filter.history-search {display:block;padding:12px 16px}
.history-primary {display:flex;align-items:end;gap:12px;flex-wrap:wrap}
.history-primary .field {flex:0 1 270px;min-width:0}
.history-primary>.link {align-self:center}
.history-more {margin-top:12px;border-top:1px solid var(--line);padding-top:8px}
.history-more>summary {cursor:pointer;font-weight:600;min-height:32px;align-content:center}
.history-fields {display:grid;grid-template-columns:repeat(auto-fit,minmax(165px,1fr));align-items:end;gap:9px 14px;padding-top:6px}
.history-fields>.field {min-width:0}
.history-fields input,.history-fields select {width:100%;min-width:0}
.history-fields .history-periods {display:flex;align-items:center;gap:6px}
.history-periods .smallbtn {white-space:nowrap;min-height:38px}
.history-apply {justify-self:start}
.history-paging {display:flex;align-items:center;gap:15px;justify-content:center;margin:18px 0}
.history-count {color:var(--muted);font-size:.875rem;margin:10px 0 6px}
@media (max-width:800px){
 .history-filter.history-search {margin:10px 0;padding:10px 12px}
 .history-primary {gap:8px}
 .history-primary .field {flex:1}
 .history-fields {grid-template-columns:repeat(2,minmax(0,1fr))}
 .history-fields select[name="company"],.history-fields select[name="org"] {max-width:100%}
 .history-fields .field:has(select[name="org"]),.history-fields .field:has(select[name="company"]) {grid-column:1/-1}
 .history-fields .history-periods {grid-column:1/-1}
 .report-rows {overflow:visible}
 .report-rows thead {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
 .report-rows table,.report-rows tbody {display:block;width:100%;min-width:0}
 .report-rows tbody {display:grid;gap:12px}
 .report-rows tr {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));padding:10px 12px;gap:7px 12px;border:1px solid var(--line);border-radius:5px}
 .report-rows td {display:block;padding:0;min-width:0;border:0;overflow-wrap:anywhere;white-space:normal}
 .report-rows td::before {content:attr(data-label);display:block;font-size:.8rem;color:var(--muted)}
}

/* Keep quantity controls compact while leaving room for a bulk quantity. */
.purchase-picker .part-picker{padding:10px 12px;border:1px solid var(--line)}
.matrix-part-head{display:flex;align-items:center;gap:10px}
.matrix-part-head strong{overflow-wrap:anywhere}
.part-thumb{width:38px;height:46px;object-fit:cover;flex:none;border-radius:3px}
.matrix-part-head .part-meta{margin:2px 0 0}
.purchase-picker .size-matrix{display:flex;flex-wrap:wrap;gap:5px 8px;margin-top:8px}
.purchase-picker .size-quantity{display:flex;flex-direction:column;align-items:center;gap:2px;border:0;overflow:visible}
.purchase-picker .size-quantity span{padding:0;background:transparent;font-size:.8rem}
.purchase-picker .size-quantity input{box-sizing:border-box;width:max(46px,calc(var(--qty-digits,3ch) + 10px));height:38px;min-height:38px;padding:0 4px;line-height:normal;font:inherit;font-variant-numeric:tabular-nums;text-align:center;border:1px solid #afa6a5;border-radius:4px;appearance:textfield;-moz-appearance:textfield}
.purchase-picker .size-quantity input::-webkit-inner-spin-button,.purchase-picker .size-quantity input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}
.purchase-picker .size-quantity:focus-within{outline:0}
.purchase-picker .size-quantity input:focus-visible{outline:2px solid var(--wine);outline-offset:1px}
.purchase-picker .part-feedback{margin:6px 0 0;font-size:.875rem}
.purchase-picker .part-feedback.incomplete,.purchase-picker .picker-message,.purchase-picker .save-status{color:#ac2033}
.purchase-picker .save-status:empty,.purchase-picker .part-feedback:empty{display:none}
.picker-scroll{container-type:inline-size}
@container(min-width:565px){
 .purchase-picker .part-picker{display:grid;grid-template-columns:minmax(135px,1fr) minmax(0,1.65fr);align-items:center;gap:4px 14px;padding:12px}
 .matrix-part-head{grid-row:1/3;align-self:start}
 .purchase-picker .size-matrix,.purchase-picker .part-feedback{grid-column:2;margin:0}
}
@media(max-width:550px){
 .picker-summary,.purchase-picker .picker-foot,.picker-scroll{padding:8px 12px}
 .picker-summary-row{gap:10px}
 .picker-summary-row .picker-product{gap:6px;font-size:.78rem}
 .picker-summary-row .picker-product>img,.picker-summary-row .picker-product>.kit-photos{width:32px;height:39px}
 .picker-stat small{font-size:.73rem}
 .picker-stat strong{font-size:1rem}
 .purchase-picker .size-matrix{gap:3px}
 .purchase-picker .size-quantity input{width:max(44px,calc(var(--qty-digits,3ch) + 10px));min-height:44px}
}
@container(max-width:305px){
 .size-matrix:has(>.size-quantity:nth-child(6):last-child){display:grid;grid-template-columns:repeat(3,max-content);gap:4px 8px}
}
.step-controls button:disabled{opacity:.52;cursor:default}
