/* KraSSell v7.1 — shared order lane (left) and production rework lane (right). */
@media (min-width:1321px) {
  body.krv7-on.krv71-docked #root main.content {
    padding:22px !important;
    min-width:0;
  }
  body.krv7-on.krv71-docked #root main.content > .content-inner {
    width:100%;
    max-width:none !important;
    min-width:0;
    margin:0 !important;
  }
  /* Filters and batch-action toolbar stay full width. The columns begin
     precisely at the first order card, not above the page title. */
  body.krv7-on.krv71-docked #krv71-lanes {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(390px,40%);
    gap:17px;
    align-items:start;
    width:100%;
    min-width:0;
    margin-top:0;
  }
  body.krv7-on.krv71-docked #krv71-lanes > .krv71-order-lane {
    min-width:0;
    width:100%;
  }
  body.krv7-on.krv71-docked #krv7-rail {
    position:sticky !important;
    top:82px !important;
    right:auto !important;
    bottom:auto !important;
    left:auto !important;
    width:100% !important;
    height:min(690px,calc(100vh - 325px)) !important;
    max-height:calc(100vh - 100px);
    min-height:400px;
    grid-column:2;
    box-shadow:0 15px 40px #1a407b15;
    border-radius:20px;
  }
  body.krv7-on.krv71-docked #krv71-lanes .order-main-row {
    grid-template-columns:26px 72px minmax(0,1fr);
    gap:11px;
    padding:14px 13px;
  }
  body.krv7-on.krv71-docked #krv71-lanes .order-thumb {
    width:72px;
    height:72px;
  }
  body.krv7-on.krv71-docked #krv71-lanes .order-actions {
    grid-column:3 / -1;
    display:flex;
    justify-content:flex-end;
    flex-wrap:wrap;
    gap:6px;
  }
  body.krv7-on.krv71-docked #krv71-lanes .order-actions .btn {
    padding:8px 10px;
    font-size:12px;
  }
  body.krv7-on.krv71-docked #krv71-lanes .product-grid {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  body.krv7-on.krv71-docked #krv71-lanes .product-item {min-width:0;}
  body.krv7-on.krv71-docked #krv71-lanes .product-name,
  body.krv7-on.krv71-docked #krv71-lanes .product-sku {overflow-wrap:anywhere;}
  body.krv7-on.krv71-docked.krv71-rail-collapsed #krv71-lanes {
    grid-template-columns:minmax(0,1fr) 62px;
  }
  body.krv7-on.krv71-docked.krv71-rail-collapsed #krv7-rail.folded {
    width:55px !important;
    height:53px !important;
    min-height:0;
    top:82px !important;
  }
}
/* On wide production monitors give each lane roughly half the usable width. */
@media (min-width:1650px) {
  body.krv7-on.krv71-docked #krv71-lanes {
    grid-template-columns:minmax(0,1fr) 49%;
  }
}
/* A distinct product type badge sits beside every recognized SKU in the shared queue. */
#krv7-rail .krv7-item-line { align-items:flex-start; }
#krv7-rail .krv71-product-id { display:flex;flex:1;min-width:0;flex-wrap:wrap;align-items:center;gap:5px 7px; }
#krv7-rail .krv71-product-id b { min-width:0;overflow-wrap:anywhere;line-height:1.5; }
#krv7-rail .krv71-product-kind {
  display:inline-flex;
  align-items:center;
  flex:none;
  padding:3px 7px;
  border:1px solid #dbe9ff;
  background:#edf5ff;
  color:#2263ba;
  border-radius:8px;
  font-size:10px;
  line-height:1.25;
  font-weight:800;
  white-space:nowrap;
}
#krv7-rail .krv7-item.done .krv71-product-kind {opacity:.75;}
#krv7-rail .krv7-item-line > span:last-child {white-space:nowrap;flex:none;padding-top:3px;}

/* KraSSell Warehouse v7.1.1 stable layout hotfix */
@media (min-width: 1321px) {
  /* Sticky right column must never paint on top of the selection toolbar. */
  body.krv7-on.krv71-docked #krv71-lanes #krv7-rail {
    z-index: 2 !important;
    min-height: min(340px, calc(100dvh - 220px)) !important;
    height: min(690px, calc(100dvh - 220px)) !important;
    max-height: calc(100dvh - 180px) !important;
  }
  /* Place the bottom toolbar above BOTH columns and allow the buttons to wrap.
     It is no longer restricted by the width or stacking of the left lane. */
  body.krv71-docked #selection-dock.show {
    z-index: 290 !important;
    display: flex !important;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-height: min(42dvh, 260px);
    padding: 11px 18px !important;
  }
  body.krv71-docked #selection-dock .selection-dock-left {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
    max-width: 215px;
  }
  body.krv71-docked #selection-dock .selection-dock-hint {
    font-size: 11px;
    line-height: 1.3;
  }
  body.krv71-docked #selection-dock .selection-dock-actions {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(min(42dvh, 260px) - 18px);
  }
  body.krv71-docked #selection-dock .selection-dock-actions > * {
    flex-shrink: 0;
    max-width: 100%;
  }
  /* When batch actions appear, float the chat ABOVE them instead of over buttons.
     The variable tracks the actual toolbar height even when actions wrap. */
}
/* The selection toolbar must win the stacking order on all screen widths. */
body.krv7-on #selection-dock.show { z-index: 290 !important; }
/* Chat stays above the bottom bar even in non-docked/mobile presentation. */
body.krv711-bottom-actions-open .krv711-chat-launcher {
  position: fixed !important;
  right: 20px !important;
  bottom: var(--krv711-chat-bottom, 112px) !important;
  z-index: 320 !important;
}

/* KraSSell Warehouse v7.1.2 batch-action layout hotfix */
/* Let the user scroll the last order fully clear of the floating action bar. */
body.krv712-bottom-actions-open #root main.content > .content-inner {
  padding-bottom: var(--krv712-dock-space, 120px) !important;
}
body.krv712-bottom-actions-open #krv71-lanes .krv71-order-lane,
body.krv712-bottom-actions-open #orders-list {
  scroll-padding-bottom: var(--krv712-dock-space, 120px);
}
body.krv712-bottom-actions-open #orders-list > .order-card:last-child {
  scroll-margin-bottom: var(--krv712-dock-space, 120px);
}
/* Do not cover action buttons with chat. Restore the launcher on deselection.
   The conversation dialog is not hidden, only compact launcher buttons. */
body.krv712-bottom-actions-open .krv711-chat-launcher,
body.krv712-bottom-actions-open .krv712-chat-launcher {
  visibility: hidden !important;
  pointer-events: none !important;
}
body.krv712-bottom-actions-open #selection-dock.show {
  z-index: 10000 !important;
}
/* Consistent row for History / Split / To assembly in compact order cards. */
@media (min-width: 1321px) {
  body.krv7-on.krv71-docked #krv71-lanes .order-main-row > .order-actions {
    grid-column: 3 / -1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    align-self: end !important;
    flex-wrap: wrap !important;
    gap: 7px !important;
    width: 100% !important;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.krv7-on.krv71-docked #krv71-lanes .order-main-row > .order-actions > .btn {
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto;
    min-height: 34px;
    height: 34px;
    padding: 7px 10px !important;
    margin: 0 !important;
    vertical-align: middle;
    font-size: 12px !important;
    line-height: 1.15 !important;
    white-space: nowrap;
  }
  body.krv7-on.krv71-docked #krv71-lanes .order-main-row > .order-actions > .history-btn {
    margin: 0 !important;
    align-self: center !important;
  }
}

/* KraSSell v7.1.3 — compact reworks, safe bulk clearing, predictable overlays. */
@media (min-width:1321px) {
  /* Right lane ≈ half its previous share: 40% -> 20%; left gets the space. */
  body.krv7-on.krv71-docked:not(.krv71-rail-collapsed) #krv71-lanes {
    grid-template-columns:minmax(0,1fr) minmax(235px,20%) !important;
    gap:12px !important;
  }
  body.krv7-on.krv71-docked #krv71-lanes #krv7-rail {min-width:0 !important;}
}
@media (min-width:1650px) {
  /* Wide screens: 49% -> 24.5%. */
  body.krv7-on.krv71-docked:not(.krv71-rail-collapsed) #krv71-lanes {
    grid-template-columns:minmax(0,1fr) minmax(270px,24.5%) !important;
  }
}
/* Maintain useful readability in a 235–300px sidebar. */
body.krv7-on.krv71-docked #krv7-rail .krv7-rail-top{padding:13px 11px 11px;gap:8px}
body.krv7-on.krv71-docked #krv7-rail .krv7-headline{gap:7px;min-width:0}
body.krv7-on.krv71-docked #krv7-rail .krv7-headline strong{font-size:14px}
body.krv7-on.krv71-docked #krv7-rail .krv7-headline small{font-size:10px}
body.krv7-on.krv71-docked #krv7-rail .krv7-logo{width:34px;height:34px;font-size:22px;flex:none}
body.krv7-on.krv71-docked #krv7-rail .krv7-summary{gap:6px;flex-wrap:wrap;padding:9px 12px}
body.krv7-on.krv71-docked #krv7-rail .krv7-list{padding:10px 7px;gap:8px}
body.krv7-on.krv71-docked #krv7-rail .krv7-item{gap:6px;padding:10px 8px}
body.krv7-on.krv71-docked #krv7-rail .krv7-crops img{width:52px;height:52px}
body.krv7-on.krv71-docked #krv7-rail .krv71-product-kind{font-size:9px;white-space:normal}
body.krv7-on.krv71-docked #krv7-rail .krv7-item-sub{overflow-wrap:anywhere}
#krv7-rail .krv713-select-label{display:inline-flex;cursor:pointer;align-items:center;justify-content:center}
#krv7-rail .krv713-select-check{width:19px;height:19px;accent-color:#1883ff;cursor:pointer}
#krv7-rail .krv713-select-check:disabled{cursor:not-allowed;opacity:.35}
#krv7-rail .krv7-item:has(.krv713-select-check:checked){border-color:#9dcaff;background:#f2f8ff;opacity:1}
#krv7-rail .krv713-task-bottom{display:flex;justify-content:space-between;align-items:center;gap:6px;flex-wrap:wrap;margin-top:8px}
#krv7-rail .krv713-task-bottom .krv7-state{margin-top:0;flex:1;min-width:100px}
#krv7-rail .krv713-complete-label{display:flex;align-items:center;gap:4px;flex:none;color:#3e6b88;font-size:11px;font-weight:800;white-space:nowrap;cursor:pointer}
#krv7-rail .krv713-complete-label input{width:16px;height:16px;accent-color:#20a478;cursor:pointer}
#krv7-rail .krv7-bottom{display:flex;flex-direction:column;align-items:stretch;gap:5px;padding:9px 10px}
#krv7-rail .krv713-clear-tools{display:flex;flex-wrap:wrap;gap:6px}
#krv7-rail .krv713-select-all{border:1px solid #d7e2f0;border-radius:9px;background:#f4f8fe;color:#35649c;font-weight:800;font-size:10px;padding:8px;cursor:pointer}
#krv7-rail .krv713-select-all:disabled{opacity:.5;cursor:not-allowed}
#krv7-rail .krv7-clear{padding:8px 9px;font-size:11px;white-space:normal}
#krv7-rail #krv7-list-count{font-size:10px}
/* Keep mass actions above ordinary cards but below all dialogs, galleries and previews.
   Earlier v7.1.2 assigned z-index:10000 and covered the photo gallery. */
body.krv7-on.krv712-bottom-actions-open #selection-dock.show{z-index:180 !important}
/* Chat launcher: hide ONLY while its panel is closed and bulk actions are visible.
   The chat dialog itself remains usable when already opened. */
body.krv712-bottom-actions-open #krtc62-shell:has(#krtc62-panel[hidden]) #krtc62-button{
  visibility:hidden !important;pointer-events:none !important;
}

/* KraSSell Warehouse v7.1.5 — synchronous chat clearance. */
body.krv715-selection-active #krtc62-button,
body:has(#selection-dock.show) #krtc62-button,
body.krv715-selection-active #krv4-chat-button,
body:has(#selection-dock.show) #krv4-chat-button{display:none!important;}
