@keyframes cosmosShimmer {
  0% { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

.skel {
  background: linear-gradient(90deg, #e8edf2 25%, #f4f7fb 50%, #e8edf2 75%);
  background-size: 600px 100%;
  animation: cosmosShimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  display: block;
}

.skel-text { height: 13px; width: 100%; margin-bottom: 8px; }
.skel-text-sm { height: 11px; width: 60%; margin-bottom: 6px; }
.skel-title { height: 20px; width: 40%; margin-bottom: 12px; }
.skel-stat { height: 44px; width: 70%; margin-bottom: 6px; }
.skel-badge { height: 20px; width: 80px; border-radius: 10px; }
.skel-btn { height: 34px; width: 120px; border-radius: 8px; }
.skel-img { height: 120px; width: 100%; border-radius: 10px; }
.skel-avatar { height: 30px; width: 30px; border-radius: 7px; }
.skel-row { height: 44px; width: 100%; border-radius: 0; margin-bottom: 1px; }

@keyframes cosmosFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page.active {
  animation: cosmosFadeIn 0.18s ease-out both;
}

@keyframes cosmosModalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.overlay.open .modal {
  animation: cosmosModalIn 0.2s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

@keyframes cosmosOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay.open {
  animation: cosmosOverlayIn 0.15s ease-out both;
}

@keyframes cosmosSpin {
  to { transform: rotate(360deg); }
}

.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: not-allowed;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  margin-left: -7px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--acc2, #2563eb);
  border-radius: 50%;
  animation: cosmosSpin 0.65s linear infinite;
}

.btn.primary.btn-loading::after {
  border-top-color: #fff;
}

@keyframes cosmosSuccessFlash {
  0% {
    background: var(--greenL, #ecfdf5);
    border-color: var(--green, #059669);
  }
  100% {
    background: inherit;
    border-color: inherit;
  }
}

.btn-success {
  animation: cosmosSuccessFlash 0.6s ease-out both;
}

#cosmos-toast-container {
  position: fixed;
  top: var(--cosmos-toast-top, calc(env(safe-area-inset-top, 0px) + 66px));
  bottom: auto;
  right: 24px;
  left: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}

@keyframes cosmosToastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cosmosToastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

.cosmos-toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  pointer-events: all;
  position: relative;
  overflow: hidden;
  background: #fff;
  animation: cosmosToastIn 0.22s ease-out both;
}

.cosmos-toast.toast-success { border: 1px solid #6ee7b7; color: #065f46; }
.cosmos-toast.toast-error { border: 1px solid #fca5a5; color: #991b1b; }
.cosmos-toast.toast-info { border: 1px solid #93c5fd; color: #1e3a8a; }
.cosmos-toast.toast-warn { border: 1px solid #fcd34d; color: #92400e; }

.cosmos-toast-close {
  margin-left: 10px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.cosmos-toast-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 10px 10px;
  transition: width linear;
}

.toast-success .cosmos-toast-bar { background: var(--green, #059669); }
.toast-error .cosmos-toast-bar { background: var(--red, #dc2626); }
.toast-info .cosmos-toast-bar { background: var(--acc2, #2563eb); }
.toast-warn .cosmos-toast-bar { background: var(--gold, #d97706); }

input.field-error,
select.field-error,
textarea.field-error {
  border-color: var(--red, #dc2626) !important;
  background: #fff8f8 !important;
}

input.field-error:focus,
select.field-error:focus,
textarea.field-error:focus {
  border-color: var(--red, #dc2626) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field-error-msg {
  display: block;
  font-size: 11px;
  color: var(--red, #dc2626);
  margin-top: 3px;
  font-weight: 500;
}

input.field-ok,
select.field-ok,
textarea.field-ok {
  border-color: var(--green, #059669) !important;
}

tbody tr.tr-link {
  cursor: pointer;
}

tbody tr.tr-link:hover td {
  background: var(--accL, #e8f4ff);
}

tbody tr.tr-link td:last-child {
  position: relative;
}

tbody tr.tr-link td:last-child::after {
  content: '›';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text3, #8b9cae);
  opacity: 0;
  transition: opacity 0.12s ease, right 0.12s ease;
}

tbody tr.tr-link:hover td:last-child::after {
  opacity: 1;
  right: 8px;
}

@media (max-width: 768px) {
  #cosmos-toast-container {
    right: 12px;
    left: 12px;
    max-width: none;
  }
  .cosmos-toast {
    min-width: 0;
    max-width: 100%;
  }
}

/* ═══ Mobile-safe overlays (Safari bottom bar + dvh) ═══ */
@media (max-width: 768px) {
  .overlay.open {
    align-items: flex-end;
    padding: 0;
  }
  .overlay.open .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(92dvh, 92vh, calc(var(--cosmos-vvh, 100dvh) * 0.92)) !important;
    border-radius: 16px 16px 0 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .overlay.open .modal .mb,
  .overlay.open .modal .modal-body,
  .overlay.open .modal .bucket-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
  }
  .overlay.open .bucket-modal-foot.is-visible {
    flex-shrink: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px) + var(--cosmos-vv-bottom, 0px));
    border-top: 1px solid var(--border, #e2e8f0);
    background: var(--card, #fff);
  }
  .overlay.open .cosmos-modal-actions:not(.bucket-modal-foot) {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 12px;
    padding: 12px 0 calc(8px + env(safe-area-inset-bottom, 0px) + var(--cosmos-vv-bottom, 0px));
    background: linear-gradient(to top, var(--card, #fff) 72%, transparent);
  }
}

@media (min-width: 769px) {
  .overlay.open .modal.modal--bucket-scan {
    max-height: min(90dvh, 90vh, calc(var(--cosmos-vvh, 100vh) * 0.9)) !important;
  }
}

/* StorePilot — Create goods request modal (native mobile bottom sheet) */
@keyframes spCreateSheetUp {
  from {
    transform: translateY(100%);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

body.sp-create-request-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.overlay.open .modal.modal--create-request {
  width: 100%;
  max-width: 960px;
  max-height: min(90dvh, 90vh, calc(var(--cosmos-vvh, 100vh) * 0.9));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: none;
}

.modal.modal--create-request .sp-create-request-head {
  flex-shrink: 0;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.modal.modal--create-request .sp-create-request-grabber {
  display: none;
  width: 40px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--border, #cbd5e1);
}

.modal.modal--create-request .sp-create-request-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}


.modal.modal--create-request .sp-create-request-head-copy {
  flex: 1;
  min-width: 0;
}

.sp-create-request-store-line {
  display: none;
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2, #64748b);
  line-height: 1.35;
}

.modal.modal--create-request .sp-create-request-close {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sp-create-request-cart-strip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 10px 16px;
  border: none;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--accL, #e8f4ff);
  color: var(--accD, #1d4ed8);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sp-create-request-cart-strip[hidden] {
  display: none !important;
}

.sp-create-request-cart-strip__icon {
  font-size: 18px;
  line-height: 1;
}

.sp-create-request-cart-strip__label {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.sp-create-request-cart-strip__cta {
  font-size: 13px;
  font-weight: 700;
  color: var(--acc, #1d6fd4);
}

.modal.modal--create-request .sp-create-request-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 16px 16px;
}

.modal.modal--create-request .sp-create-request-layout {
  gap: 14px;
}

.modal.modal--create-request .sp-create-request-search-card,
.modal.modal--create-request .sp-create-request-cart-card,
.modal.modal--create-request .sp-create-request-meta-card {
  border-radius: 12px;
}

.modal.modal--create-request .sp-create-request-meta-inner {
  padding: 0 16px 16px;
}

.modal.modal--create-request .sp-create-request-field {
  margin-bottom: 14px;
}

.modal.modal--create-request .sp-create-request-field:last-child {
  margin-bottom: 0;
}

.modal.modal--create-request .sp-create-request-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text2, #64748b);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal.modal--create-request .sp-create-request-dest {
  font-size: 14px;
  color: var(--text1, #0f172a);
  padding: 10px 12px;
  background: var(--bg, #f8fafc);
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 10px;
}

.modal.modal--create-request .sp-create-request-err {
  margin: 8px 16px 0;
}

.modal.modal--create-request .sp-create-request-results {
  max-height: none;
}

#overlay-sp-create-request .avail-row,
#overlay-sp-create-request .cart-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.modal.modal--create-request .sp-create-request-foot {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
  box-shadow: 0 -4px 24px rgba(15, 30, 53, 0.06);
}

.modal.modal--create-request .sp-create-request-foot-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.modal.modal--create-request .sp-create-request-msg {
  font-size: 12px;
  color: var(--text2, #64748b);
  min-height: 0;
  width: 100%;
}

.modal.modal--create-request .sp-create-request-msg:not(:empty) {
  min-height: 16px;
}

@media (min-width: 769px) {
  #overlay-sp-create-request .sp-create-request-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }

  #overlay-sp-create-request .sp-cr-results-block {
    border: none;
  }

  #overlay-sp-create-request .sp-cr-results-head {
    display: none !important;
  }

  #overlay-sp-create-request .sp-create-request-results {
    max-height: 280px;
    overflow-y: auto;
  }

  #overlay-sp-create-request .sp-cr-search-block {
    padding: 0;
    border: none;
  }

  #overlay-sp-create-request .sp-cr-cart-block {
    border: none;
    padding: 0;
  }

  #overlay-sp-create-request .sp-cr-notes-block {
    padding: 0;
  }

  .modal.modal--create-request .sp-create-request-foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  .modal.modal--create-request .sp-create-request-msg {
    flex: 1 1 auto;
    max-width: 50%;
  }
  .modal.modal--create-request .sp-create-request-foot-btns {
    width: auto;
    margin-left: auto;
  }
}

/* Create request — mobile sheet (StorePilot) */
.sp-cr-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1, #0f172a);
  margin-bottom: 6px;
}

.sp-cr-empty-sub {
  font-size: 13px;
  color: var(--text2, #64748b);
}

.sp-cr-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 6px;
}

.sp-cr-results-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3, #94a3b8);
}

.sp-cr-results-count {
  font-size: 11px;
  color: var(--text3, #94a3b8);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

@media (max-width: 768px) {
  #overlay-sp-create-request.overlay.open {
    align-items: flex-end;
    padding: 0;
    overscroll-behavior: contain;
  }

  #overlay-sp-create-request.overlay.open .modal.modal--create-request {
    width: 100% !important;
    max-width: 100% !important;
    height: min(96dvh, calc(var(--cosmos-vvh, 100dvh) * 0.96));
    max-height: min(96dvh, calc(var(--cosmos-vvh, 100dvh) * 0.96)) !important;
    border-radius: 20px 20px 0 0;
    margin: 0;
    animation: spCreateSheetUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  }

  @media (prefers-reduced-motion: reduce) {
    #overlay-sp-create-request.overlay.open .modal.modal--create-request {
      animation: none;
    }
  }

  #overlay-sp-create-request .sp-cr-desktop-only {
    display: none !important;
  }

  #overlay-sp-create-request .sp-create-request-grabber {
    display: block;
  }

  #overlay-sp-create-request .sp-create-request-head {
    padding: 8px 16px 12px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    border-bottom: 1px solid var(--border, #e2e8f0);
  }

  #overlay-sp-create-request .sp-create-request-store-line {
    display: block;
    font-size: 12px;
    margin-top: 4px;
  }

  #overlay-sp-create-request .sp-create-request-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0;
  }

  #overlay-sp-create-request .sp-cr-sheet,
  #overlay-sp-create-request .sp-create-request-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: min-content;
  }

  #overlay-sp-create-request .sp-cr-pane {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 100%;
  }

  #overlay-sp-create-request .sp-cr-search-block {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: var(--card, #fff);
    flex-shrink: 0;
  }

  #overlay-sp-create-request .sp-create-request-search-card {
    background: transparent;
    border: none;
    box-shadow: none;
    margin: 0;
    border-radius: 0;
  }

  #overlay-sp-create-request .sp-create-request-search-card .ch {
    padding: 0;
    border: none;
    margin: 0;
  }

  #overlay-sp-create-request .sp-cr-search-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 !important;
    max-width: none !important;
    background: var(--bg, #f8fafc);
    border: 1.5px solid var(--border, #e2e8f0);
    border-radius: 10px;
    padding: 0 12px;
    min-height: 44px;
  }

  #overlay-sp-create-request .sp-create-request-search-input {
    flex: 1;
    width: 100%;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 0;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  #overlay-sp-create-request .sp-create-request-err {
    margin: 8px 0 0;
  }

  #overlay-sp-create-request .sp-cr-results-block {
    border-bottom: 1px solid var(--border, #e2e8f0);
    background: var(--card, #fff);
    flex-shrink: 0;
  }

  #overlay-sp-create-request .sp-cr-results-block:not(.sp-cr-results-block--active) .sp-cr-results-head {
    display: none;
  }

  #overlay-sp-create-request .sp-cr-results-block--active .sp-cr-results-head {
    display: flex;
    padding: 8px 16px 4px;
  }

  #overlay-sp-create-request .sp-create-request-results {
    max-height: min(36dvh, calc(var(--cosmos-vvh, 100dvh) * 0.34));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #overlay-sp-create-request .sp-cr-results-block:not(.sp-cr-results-block--active) .sp-create-request-results {
    max-height: none;
    overflow: visible;
  }

  #overlay-sp-create-request .sp-cr-empty-hint {
    padding: 16px;
    text-align: center;
  }

  #overlay-sp-create-request .sp-cr-cart-block,
  #overlay-sp-create-request .sp-cr-notes-block {
    background: var(--card, #fff);
    border: none;
    box-shadow: none;
    border-radius: 0;
    margin: 0;
  }

  #overlay-sp-create-request .sp-cr-cart-block {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
  }

  #overlay-sp-create-request .sp-cr-cart-block .ch {
    padding: 0 0 10px;
    border: none;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  #overlay-sp-create-request .sp-cr-cart-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
  }

  #overlay-sp-create-request .sp-cr-empty-cart {
    text-align: center;
    padding: 16px 0;
    color: var(--text3, #94a3b8);
    font-size: 13px;
  }

  #overlay-sp-create-request .sp-cr-empty-cart .empty-ic {
    font-size: 28px;
    opacity: 0.45;
    margin-bottom: 6px;
  }

  #overlay-sp-create-request .sp-cr-notes-block {
    padding: 0 16px 12px;
  }

  #overlay-sp-create-request .sp-cr-notes-block .sp-create-request-meta-inner {
    padding: 0;
  }

  #overlay-sp-create-request .sp-cr-notes-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text3, #94a3b8);
    margin-bottom: 6px;
  }

  #overlay-sp-create-request .sp-create-request-notes {
    width: 100%;
    font-size: 16px;
    min-height: 72px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1.5px solid var(--border, #e2e8f0);
    background: var(--bg, #f8fafc);
    resize: none;
  }

  #overlay-sp-create-request .sp-cr-notes-field {
    margin-bottom: 0;
  }

  #overlay-sp-create-request .avail-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 10px 16px;
    border-top: 1px solid var(--border, #e2e8f0);
    margin: 0;
    background: var(--card, #fff);
  }

  #overlay-sp-create-request .avail-row:first-child {
    border-top: none;
  }

  #overlay-sp-create-request .avail-row .btn {
    min-height: 36px;
    min-width: 64px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 999px;
    flex-shrink: 0;
  }

  #overlay-sp-create-request .cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--border, #e2e8f0);
    min-height: 0;
    flex-wrap: nowrap;
  }

  #overlay-sp-create-request .cart-item:first-child {
    border-top: none;
  }

  #overlay-sp-create-request .cart-item .qty-input {
    width: 72px;
    min-height: 40px;
    font-size: 16px;
    border-radius: 8px;
  }

  #overlay-sp-create-request .cart-item .btn {
    min-width: 40px;
    min-height: 40px;
  }

  #overlay-sp-create-request .overlay.open .sp-create-request-foot,
  #overlay-sp-create-request .sp-create-request-foot {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px) + var(--cosmos-vv-bottom, 0px));
    gap: 8px;
    border-top: 1px solid var(--border, #e2e8f0);
    box-shadow: none;
  }

  #overlay-sp-create-request .sp-create-request-foot-btns {
    flex-direction: column;
    width: 100%;
    margin: 0;
    gap: 8px;
  }

  #overlay-sp-create-request .sp-create-request-submit-btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    border-radius: 10px;
    order: 1;
  }

  #overlay-sp-create-request .sp-create-request-clear-btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
    font-size: 13px;
    background: transparent;
    border-color: transparent;
    color: var(--text2, #64748b);
    order: 2;
  }

  /* Foundry create transfer — simple stacked scroll (no overlap) */
  #overlay-ftr-create-transfer .sp-create-request-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
  }

  #overlay-ftr-create-transfer .sp-create-request-layout.two-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .modal.modal--create-request .sp-create-request-grabber {
    display: block;
  }
}

/* Foundry — Goods Request history search modal */
.overlay.open .modal.modal--ftr-history {
  width: 100%;
  max-width: 560px;
  max-height: min(88dvh, 88vh, calc(var(--cosmos-vvh, 100vh) * 0.88));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: none;
}

.modal.modal--ftr-history .sp-ftr-history-head {
  flex-shrink: 0;
  flex-direction: column;
  align-items: stretch;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.modal.modal--ftr-history .sp-ftr-history-grabber {
  display: none;
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border, #cbd5e1);
  margin: 0 auto 10px;
}

.modal.modal--ftr-history .sp-ftr-history-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal.modal--ftr-history .sp-ftr-history-close {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
}

.modal.modal--ftr-history .sp-ftr-history-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 10px 14px;
  position: relative;
}

#overlay-ftr-history .sp-ftr-history-body .flatpickr-calendar.ftr-history-flatpickr {
  position: absolute;
  z-index: 25;
}

.modal.modal--ftr-history .ftr-history-form .fg {
  margin-bottom: 8px;
  min-width: 0;
}

.modal.modal--ftr-history .ftr-history-dates-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.modal.modal--ftr-history .ftr-history-dates-row .fg {
  margin-bottom: 0;
}

.modal.modal--ftr-history .ftr-history-optional-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 0;
}

.modal.modal--ftr-history .ftr-history-optional-row .fg {
  margin-bottom: 0;
}

.modal.modal--ftr-history .ftr-history-optional-full {
  grid-column: 1 / -1;
}

.modal.modal--ftr-history .ftr-history-hint {
  font-size: 11px;
  color: var(--text2, #64748b);
  margin: 0 0 8px;
  line-height: 1.35;
}

.modal.modal--ftr-history .ftr-history-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.modal.modal--ftr-history .ftr-history-label--date {
  font-size: 10px;
}

.modal.modal--ftr-history .ftr-history-datepicker.inp {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
}

/* Native OS date picker (History modal — phones / coarse pointers): large tap targets, no zoom on iOS focus */
.modal.modal--ftr-history input[type="date"].inp.ftr-history-datepicker.ftr-history-date-native {
  min-height: 48px;
  padding: 11px 12px;
  font-size: 16px;
  line-height: 1.25;
  color: var(--text1);
  width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.modal.modal--ftr-history input[type="date"].ftr-history-date-native::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.9;
}

.modal.modal--ftr-history .ftr-history-optional {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text3);
}

.modal.modal--ftr-history .ftr-history-store-row {
  margin-bottom: 12px;
}

.modal.modal--ftr-history .ftr-history-store-row .ftr-store-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.modal.modal--ftr-history .ftr-history-results {
  margin-top: 8px;
}

.modal.modal--ftr-history .ftr-history-list.cosmos-record-list {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card, #fff);
}

.modal.modal--ftr-history .ftr-history-list .ftr-history-row.cosmos-record-row {
  padding: 10px 12px;
}

.modal.modal--ftr-history .ftr-history-row__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  line-height: 1.35;
}

.modal.modal--ftr-history .ftr-history-row__dates,
.modal.modal--ftr-history .ftr-history-row__scores {
  font-size: 12px;
  color: var(--text2, #64748b);
}

.modal.modal--ftr-history .ftr-history-row__score-num {
  font-weight: 600;
  color: var(--text1, #0f172a);
}

.modal.modal--ftr-history .ftr-history-list .cosmos-record-row__secondary {
  display: none;
}

.modal.modal--ftr-history .ftr-history-datepicker {
  cursor: pointer;
}

/* History date picker — card-style calendar (reference: centered month/year, rounded nav) */
.flatpickr-calendar.ftr-history-flatpickr {
  z-index: 1320;
  width: 280px;
  max-width: calc(100vw - 28px);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  padding: 12px 10px 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  box-sizing: border-box;
}

.flatpickr-calendar.ftr-history-flatpickr::before,
.flatpickr-calendar.ftr-history-flatpickr::after {
  display: none;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-months {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px 10px;
  height: auto;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-month {
  flex: 1 1 auto;
  height: auto;
  overflow: visible;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-current-month {
  position: static;
  left: auto;
  width: 100%;
  height: auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text1, #0f172a);
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-current-month .cur-month,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-current-month .flatpickr-monthDropdown-months {
  font-size: 15px;
  font-weight: 700;
  color: var(--text1, #0f172a);
  pointer-events: none;
}

.flatpickr-calendar.ftr-history-flatpickr select.flatpickr-monthDropdown-months {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Fallback if native select still renders elsewhere */
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-monthDropdown-months {
  font-size: 13px !important;
  font-weight: 600;
  line-height: 1.3;
  max-height: 160px;
  padding: 2px 4px;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-current-month input.cur-year {
  font-size: 15px;
  font-weight: 700;
  color: var(--text1, #0f172a);
  pointer-events: none;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
  margin: 0;
  width: auto;
  min-width: 0;
}

.flatpickr-calendar.ftr-history-flatpickr .numInputWrapper .arrowUp,
.flatpickr-calendar.ftr-history-flatpickr .numInputWrapper .arrowDown {
  display: none;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-prev-month,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-next-month {
  position: static;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #f8fafc);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  fill: var(--text2, #64748b);
  transition: background 0.15s, border-color 0.15s;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-prev-month:hover,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-next-month:hover {
  background: var(--accL, #e8f4ff);
  border-color: var(--acc2, #2b8cff);
  fill: var(--acc, #1d6fd4);
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-weekdays {
  height: auto;
  margin-bottom: 4px;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-weekdaycontainer {
  display: flex;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-weekday {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3, #94a3b8);
  line-height: 1.2;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-days {
  width: 100%;
  box-sizing: border-box;
}

.flatpickr-calendar.ftr-history-flatpickr .dayContainer {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day {
  max-width: none;
  flex: 1 0 14.28%;
  height: 34px;
  line-height: 34px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text1, #0f172a);
  border: none;
  border-radius: 999px;
  box-sizing: border-box;
  margin: 1px 0;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.prevMonthDay,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.nextMonthDay {
  color: var(--text3, #94a3b8);
  opacity: 0.5;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day:hover {
  background: var(--accL, #e8f4ff);
  border-color: transparent;
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.today {
  border: 1px solid var(--acc2, #2b8cff);
}

.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.selected,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.selected:hover,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.startRange,
.flatpickr-calendar.ftr-history-flatpickr .flatpickr-day.endRange {
  background: var(--acc, #1d6fd4);
  border-color: var(--acc, #1d6fd4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(29, 111, 212, 0.28);
}

.modal.modal--ftr-history .sp-ftr-history-foot {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border, #e2e8f0);
}

.modal.modal--ftr-history .sp-ftr-history-foot .btn {
  min-height: 42px;
  touch-action: manipulation;
}

/* ═══ Cosmos date picker (Flatpickr — dd/MM/yyyy display) ═══ */
input.cosmos-date-picker,
input.cosmos-date-picker.flatpickr-input {
  min-height: 40px;
  cursor: pointer;
}

input.cosmos-date-picker[readonly] {
  background: var(--card, #fff);
  color: var(--text1, #0f172a);
}

.flatpickr-calendar.cosmos-flatpickr {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  font-family: inherit;
  z-index: 10060;
}

input.cosmos-date-picker-native[type="date"] {
  min-height: 40px;
  font-size: 16px;
  cursor: pointer;
  color-scheme: light;
}

input.cosmos-date-picker-native[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
  padding: 4px;
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-months {
  background: var(--bg, #f8fafc);
  border-bottom: 1px solid var(--border, #e2e8f0);
  border-radius: 10px 10px 0 0;
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-current-month {
  color: var(--text1, #0f172a);
  font-weight: 600;
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-weekday {
  color: var(--text2, #64748b);
  font-weight: 600;
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-day {
  color: var(--text1, #0f172a);
  border-radius: 6px;
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-day:hover {
  background: var(--accL, #eff6ff);
  border-color: var(--accL, #eff6ff);
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-day.today {
  border-color: var(--acc, #2563eb);
}

.flatpickr-calendar.cosmos-flatpickr .flatpickr-day.selected,
.flatpickr-calendar.cosmos-flatpickr .flatpickr-day.selected:hover {
  background: var(--acc, #2563eb);
  border-color: var(--acc, #2563eb);
  color: #fff;
}

@media (max-width: 768px) {
  #overlay-ftr-history.overlay.open {
    align-items: flex-end;
    padding: 0;
  }

  #overlay-ftr-history.overlay.open .modal.modal--ftr-history {
    width: 100%;
    max-width: none;
    max-height: min(92dvh, 92vh, calc(var(--cosmos-vvh, 100vh) * 0.92));
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .modal.modal--ftr-history .sp-ftr-history-grabber {
    display: block;
  }

  .modal.modal--ftr-history .sp-ftr-history-foot {
    flex-direction: column-reverse;
  }

  .modal.modal--ftr-history .sp-ftr-history-foot .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ═══ App shell — fixed chrome + single content scroll (native mobile feel) ═══ */
body.cosmos-app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body.cosmos-app-shell .main {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.cosmos-app-shell .main > .topbar,
body.cosmos-app-shell .main > .cx-mob-bar {
  flex-shrink: 0;
  position: relative;
  top: auto;
  z-index: 50;
}

body.cosmos-app-shell .cosmos-app-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* StorePilot / Foundry pages with inner .sp-page-body — single scroll region (no outer + inner fight) */
body.cosmos-app-shell .cosmos-app-scroll:has(.page.active .sp-page-body) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.cosmos-app-shell .cosmos-app-scroll:has(.page.active .sp-page-body) > .page.active {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar footer — sign out beside user name (not in nav scroll) */
.sidebar-user-meta {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.sidebar-user-name-row .u-name,
.sidebar-user-name-row .user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-logout-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}
.sidebar-logout-btn:hover,
.sidebar-logout-btn:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}
.sidebar-logout-btn:active {
  background: rgba(255, 255, 255, 0.14);
}
.sidebar-logout-btn svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* Sidebar — no header branding; nav starts at top */
.sidebar-logo {
  display: none !important;
}
.sidebar .sidebar-nav {
  padding-top: 12px;
}

/* Sidebar footer — minimal module switcher */
.sidebar-user--with-modules {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-top: auto;
  background: rgba(0, 0, 0, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-user-top {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px 0;
}
.sidebar-user--with-modules.sidebar-user {
  padding: 0;
}
.sidebar-user--with-modules .u-role,
.sidebar-user--with-modules .user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.32);
}
.sidebar-user--with-modules .u-name,
.sidebar-user--with-modules .user-name {
  font-size: 13px;
  font-weight: 600;
}
.sidebar-logout-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}
.sidebar-logout-btn svg {
  width: 16px;
  height: 16px;
}
#cosmos-module-switch-footer {
  width: 100%;
}
#cosmos-module-switch-footer[hidden] {
  display: none !important;
}

.cosmos-module-hub-link {
  display: block;
  width: 100%;
  padding: 8px 14px 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}
.cosmos-module-hub-link:hover {
  color: rgba(255, 255, 255, 0.92);
}
.cosmos-module-hub-link:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.65);
  outline-offset: 2px;
  border-radius: 4px;
}

.cosmos-sidebar-footer-modules {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 14px;
}

.cosmos-module-active {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 0 2px;
  margin: 0;
  border: none;
}
.cosmos-module-active-cap {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.28);
  line-height: 1;
}
.cosmos-module-active-lbl {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.cosmos-module-switch {
  position: relative;
  width: 100%;
  padding: 0;
}
.cosmos-module-flyout {
  display: none !important;
}
.cosmos-module-strip-wrap {
  display: block;
  width: 100%;
}
.cosmos-module-strip {
  display: flex;
  flex-direction: row;
  gap: 4px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cosmos-module-chip {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.12s ease, background 0.12s ease, transform 0.12s ease;
}
.cosmos-module-chip:hover:not(:disabled) {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.08);
}
.cosmos-module-chip.is-active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
  cursor: default;
}
.cosmos-module-chip:disabled {
  opacity: 1;
}
.cosmos-module-chip-ic {
  font-size: 14px;
  line-height: 1;
}

/* ── ERP mobile shell — hamburger + off-canvas sidebar (Command Unit parity) ── */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  background: var(--bg, #f4f7fb);
  border: 1.5px solid var(--border, #e2e8f0);
  cursor: pointer;
  flex-shrink: 0;
  flex-direction: column;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: var(--text1, #0f172a);
}
.menu-toggle span:nth-child(2) {
  margin: 3px 0;
}

.sidebar-overlay,
.cu-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 53, 0.45);
  z-index: 150;
}
.sidebar-overlay.open,
.cu-sidebar-overlay.open {
  display: block;
}

/* Inactive Foundry/StorePilot pages must stay hidden (page-specific flex rules must not override .page) */
body.cosmos-app-shell .cosmos-app-scroll > .page:not(.active) {
  display: none !important;
}

body.cosmos-app-shell .sidebar {
  height: 100dvh;
}

@media (max-width: 1024px) {
  body.cosmos-app-shell .main > .topbar {
    position: sticky;
    top: 0;
    z-index: 120;
    background: var(--card, #fff);
    border-bottom: 1px solid var(--border, #e2e8f0);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  }
}

@media (max-width: 1024px) {
  body.cosmos-app-shell .menu-toggle {
    display: flex;
  }
  body.cosmos-app-shell .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    position: fixed;
    z-index: 200;
    pointer-events: none;
  }
  body.cosmos-app-shell .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(15, 30, 53, 0.28);
    pointer-events: auto;
    padding-top: env(safe-area-inset-top, 0px);
  }
  body.cosmos-app-shell .main {
    margin-left: 0 !important;
  }
  body.cosmos-app-shell .topbar,
  body.cosmos-app-shell .main > .topbar {
    padding-left: 14px;
    padding-right: 14px;
    gap: 10px;
    min-height: 52px;
    height: auto;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: 8px;
    align-items: flex-start;
    flex-wrap: nowrap;
  }
  body.cosmos-app-shell .topbar-center {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding-top: 2px;
  }
  body.cosmos-app-shell .breadcrumb,
  body.cosmos-app-shell .topbar-breadcrumb {
    min-width: 0;
    width: 100%;
    flex: none;
    overflow: visible;
    white-space: normal;
    text-overflow: unset;
    line-height: 1.35;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
  }
  body.cosmos-app-shell .breadcrumb .cur,
  body.cosmos-app-shell .topbar-breadcrumb .cur {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  body.cosmos-app-shell .breadcrumb-prefix {
    display: none;
  }
  body.cosmos-app-shell .topbar-updated {
    font-size: 11px;
    color: var(--text3, #8b9cae);
    line-height: 1.3;
    max-width: 100%;
  }
  body.cosmos-app-shell .topbar-updated:empty {
    display: none;
  }
  body.cosmos-app-shell .sp-page-title-row {
    flex-direction: column;
    align-items: stretch;
  }
  body.cosmos-app-shell .sp-page-tools {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  body.cosmos-app-shell .sp-page-tools .sw {
    width: 100% !important;
    max-width: none !important;
  }
  body.cosmos-app-shell .sp-page-tools .btn {
    width: 100%;
    justify-content: center;
  }
  body.cosmos-app-shell #page-transfers-history .sp-page-head {
    flex-shrink: 0;
    background: var(--card, #fff);
    z-index: 2;
  }
  body.cosmos-app-shell #page-transfers-history .sp-page-filters {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  body.cosmos-app-shell #page-transfers-history .sp-page-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.cosmos-app-shell #page-transfer-requests.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
    padding-bottom: 0 !important;
  }
  body.cosmos-app-shell #page-transfer-requests .cosmos-page-head {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--card, #fff);
    padding-bottom: 10px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border, #e2e8f0);
  }
  body.cosmos-app-shell #page-transfer-requests .sp-page-title-row {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }
  body.cosmos-app-shell #page-transfer-requests .sp-page-tools {
    width: auto;
    flex-direction: row;
    flex-shrink: 0;
  }
  body.cosmos-app-shell #page-transfer-requests .sp-page-tools .btn {
    width: auto;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }
  body.cosmos-app-shell #page-transfer-requests .sp-page-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: 10px;
  }
  body.cosmos-app-shell #page-transfer-requests .ftr-request-list-card {
    border: none;
    box-shadow: none;
    background: transparent;
  }
  body.cosmos-app-shell #page-transfer-requests .cosmos-page-head .sp-page-filters {
    margin-bottom: 0;
    gap: 8px;
  }
  body.cosmos-app-shell #page-transfer-requests .ps {
    font-size: 12px;
    line-height: 1.35;
    margin-top: 2px;
  }
  #page-transfer-requests .ftr-store-chips,
  #page-transfer-requests .ftr-status-tabs,
  #page-lab-orders .ftr-store-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 8px;
  }
  #page-transfer-requests .ftr-store-chips .btn.sm,
  #page-transfer-requests .ftr-status-tabs .btn.sm,
  #page-lab-orders .ftr-store-chips .btn.sm {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #page-transfer-requests .ftr-store-chips .btn.sm {
    max-width: none;
    text-align: center;
    line-height: 1.25;
  }
  #page-lab-orders .ftr-store-chips .btn.sm {
    max-width: none;
    text-align: center;
    line-height: 1.25;
  }
  #page-transfer-requests .cosmos-record-row,
  #page-transfer-requests .ftr-request-card {
    min-height: 56px;
    touch-action: manipulation;
  }
  body.cosmos-app-shell .cosmos-app-scroll .page {
    padding: 14px;
  }
  body.cosmos-app-shell .nav-item {
    min-height: 48px;
    touch-action: manipulation;
  }
}

/* Mobile/tablet shells: block pinch-zoom; prevent iOS input focus zoom */
@media (pointer: coarse), (max-width: 1024px) {
  html.cosmos-lock-zoom,
  html.cosmos-lock-zoom body {
    touch-action: pan-x pan-y;
  }
  html.cosmos-lock-zoom input,
  html.cosmos-lock-zoom select,
  html.cosmos-lock-zoom textarea {
    font-size: 16px;
  }
}

@media print {
  body.cosmos-app-shell {
    height: auto;
    overflow: visible;
  }
  body.cosmos-app-shell .main {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  body.cosmos-app-shell .cosmos-app-scroll {
    overflow: visible !important;
    height: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Order Timeline — shared component
   ═══════════════════════════════════════════════════════════════════════════ */

/* Progress track at the top of the modal */
.cosmos-timeline-track {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 10px 0 16px;
  scrollbar-width: none;
}

.cosmos-tl-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 0 auto;
  min-width: 68px;
  position: relative;
}
.cosmos-tl-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 11px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border, #e2e8f0);
  z-index: 0;
}
.cosmos-tl-step.done:not(:last-child)::after,
.cosmos-tl-step.current:not(:last-child)::after {
  background: var(--green, #16a34a);
}
.cosmos-tl-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border, #e2e8f0);
  background: var(--bg, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  position: relative;
  z-index: 1;
  transition: background 0.15s, border-color 0.15s;
}
.cosmos-tl-step.done .cosmos-tl-dot {
  background: var(--green, #16a34a);
  border-color: var(--green, #16a34a);
  color: #fff;
}
.cosmos-tl-step.current .cosmos-tl-dot {
  background: var(--acc, #2563eb);
  border-color: var(--acc, #2563eb);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.18);
}
.cosmos-tl-step.fail .cosmos-tl-dot {
  background: var(--red, #dc2626);
  border-color: var(--red, #dc2626);
  color: #fff;
}
.cosmos-tl-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text3, #8b9cae);
  margin-top: 5px;
  text-align: center;
  max-width: 64px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.cosmos-tl-step.done .cosmos-tl-label,
.cosmos-tl-step.current .cosmos-tl-label { color: var(--text2, #475569); }

/* Log entries list */
.cosmos-timeline-log {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 4px;
}
.cosmos-tl-entry {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
  position: relative;
}
.cosmos-tl-entry:last-child { border-bottom: none; }
.cosmos-tl-entry-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green, #16a34a);
  margin-top: 5px;
  flex-shrink: 0;
}
.cosmos-tl-entry-dot.fail { background: var(--red, #dc2626); }
.cosmos-tl-entry-dot.info { background: var(--acc, #2563eb); }
.cosmos-tl-entry-body { flex: 1; min-width: 0; }
.cosmos-tl-entry-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text1, #0f172a);
}
.cosmos-tl-entry-meta {
  font-size: 11px;
  color: var(--text3, #8b9cae);
  margin-top: 2px;
}
.cosmos-tl-entry-note {
  font-size: 12px;
  color: var(--text2, #475569);
  background: var(--accL, #eff6ff);
  border-left: 3px solid var(--acc2, #3b82f6);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  margin-top: 5px;
}

/* Modal wrapper */
.cosmos-timeline-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.cosmos-timeline-modal-overlay.open {
  display: flex;
}
.cosmos-timeline-modal {
  background: var(--card, #fff);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  animation: cosmos-tl-slide-in 0.2s ease;
}
@keyframes cosmos-tl-slide-in {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cosmos-timeline-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.cosmos-timeline-modal-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text1, #0f172a);
}
.cosmos-timeline-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text3, #8b9cae);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}
.cosmos-timeline-modal-close:hover { background: var(--border, #e2e8f0); }
.cosmos-timeline-modal-body {
  padding: 16px 20px 20px;
  max-height: 70vh;
  overflow-y: auto;
}

/* Shared order detail modal (long-press on lab / order lists) */
.cosmos-order-detail-modal { max-width: 640px; }
.cosmos-od-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.cosmos-od-order-no {
  font-size: 17px;
  font-weight: 800;
  color: var(--text1, #0f172a);
}
.cosmos-od-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accL, #eff6ff);
  color: var(--acc2, #4f46e5);
}
.cosmos-od-meta { font-size: 14px; color: var(--text2, #475569); margin-bottom: 14px; }
.cosmos-od-muted { font-size: 12px; color: var(--text3, #64748b); margin-top: 4px; }
.cosmos-od-section {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.cosmos-od-section-h {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2, #475569);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cosmos-od-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border, #e2e8f0);
}
.cosmos-od-line:first-of-type { border-top: none; padding-top: 0; }
.cosmos-od-line-title { font-size: 14px; font-weight: 600; color: var(--text1, #0f172a); }
.cosmos-od-line-amt { font-size: 13px; font-weight: 600; color: var(--text1, #0f172a); white-space: nowrap; }
.cosmos-od-pay-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text2, #475569);
}
.cosmos-od-summary { font-size: 13px; color: var(--text2, #475569); line-height: 1.6; }
[data-order-id].tr-link { cursor: pointer; }

/* ═══════════════════════════════════════════════════════════════════════════
   Global minimal scrollbars (standard scrollbar-width / scrollbar-color;
   supported in Firefox and Chromium — avoids ::-webkit-scrollbar in Firefox).
   Overrides that hide scrollbars (e.g. .cosmos-timeline-track) use scrollbar-width: none.
   ═══════════════════════════════════════════════════════════════════════════ */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border, #cbd5e1) transparent;
}

/* Overlay stacking: detail backdrop 240, panel 250, bucket 400 (above shell .overlay 300; toasts ~10000) */
:root {
  --cosmos-z-detail-backdrop: 240;
  --cosmos-z-detail-panel: 250;
  --cosmos-z-bucket-overlay: 400;
}

/* ═══ Bucket scan modal (TRANSFER / RECEIVE) ═══ */
#modal-bucket-scan.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--cosmos-z-bucket-overlay, 280);
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(12px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.42);
}

#modal-bucket-scan.overlay.open {
  display: flex;
}

#modal-bucket-scan .modal.modal--bucket-scan {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 96vw;
  max-width: 520px;
  max-height: min(90dvh, 90vh);
  background: var(--card, #fff);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

#modal-bucket-scan .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

#modal-bucket-scan .modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text1, #0f172a);
}

#modal-bucket-scan .modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text2, #64748b);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

#modal-bucket-scan .modal-close:hover {
  background: var(--redL, #fee2e2);
  color: var(--red, #dc2626);
}

#modal-bucket-scan .b {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

#modal-bucket-scan .b-blue {
  background: var(--blueL, #dbeafe);
  color: var(--blue, #2563eb);
}

#modal-bucket-scan .b-green {
  background: var(--greenL, #dcfce7);
  color: var(--green, #16a34a);
}

#modal-bucket-scan .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text1, #0f172a);
  transition: all 0.15s;
  white-space: nowrap;
}

#modal-bucket-scan .btn:hover {
  border-color: var(--acc2, #6366f1);
  color: var(--acc, #4f46e5);
}

#modal-bucket-scan .btn.primary {
  background: var(--acc, #4f46e5);
  border-color: var(--acc, #4f46e5);
  color: #fff;
}

#modal-bucket-scan .btn.sm {
  padding: 5px 10px;
  font-size: 12px;
}

#modal-bucket-scan .btn:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

#modal-bucket-scan .bucket-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#modal-bucket-scan .bucket-modal-foot {
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px) + var(--cosmos-vv-bottom, 0px));
  border-top: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
}

#modal-bucket-scan .bucket-modal-foot.is-visible {
  display: flex;
}

#modal-bucket-scan .bucket-modal-foot .bucket-foot-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#modal-bucket-scan .bucket-modal-foot .btn {
  min-height: 44px;
  flex: 1 1 auto;
}

#modal-bucket-scan .bucket-scan-viewport {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  touch-action: manipulation;
}
#modal-bucket-scan .bucket-focus-reticle {
  position: absolute;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border: 2px solid var(--acc2);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--card);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}
#modal-bucket-scan .bucket-focus-reticle.is-visible {
  opacity: 1;
}
#modal-bucket-scan .bucket-scan-focus-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text3);
  text-align: center;
}
#modal-bucket-scan .bucket-scan-status {
  min-height: 0;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  padding: 0;
}
#modal-bucket-scan .bucket-scan-status:not(:empty) {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
#modal-bucket-scan .bucket-scan-status--warn {
  color: var(--gold);
  background: var(--goldL);
  border-color: var(--gold);
}
#modal-bucket-scan .bucket-scan-status--err {
  color: var(--red);
  background: var(--redL);
  border-color: var(--red);
}
#modal-bucket-scan .bucket-scan-status--ok {
  color: var(--green);
  background: var(--greenL);
  border-color: var(--green);
}
#modal-bucket-scan .bucket-show-qr-row {
  margin-top: 8px;
}
#modal-bucket-scan .bucket-scanned-list-wrap.is-collapsed {
  display: none;
}
#modal-bucket-scan .bucket-scanned-list-wrap:not(.is-collapsed) {
  display: block;
  margin-top: 8px;
}
#modal-bucket-scan #bucket-video {
  width: 100%;
  display: block;
  min-height: 160px;
  max-height: min(42dvh, 280px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
#modal-bucket-scan .bucket-scan-frame {
  position: absolute;
  inset: 10% 8%;
  pointer-events: none;
  z-index: 1;
}
#modal-bucket-scan .bucket-scan-frame__c {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: var(--acc2);
  border-style: solid;
  box-sizing: border-box;
}
#modal-bucket-scan .bucket-scan-frame__c--tl {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
}
#modal-bucket-scan .bucket-scan-frame__c--tr {
  top: 0;
  right: 0;
  border-width: 3px 3px 0 0;
}
#modal-bucket-scan .bucket-scan-frame__c--bl {
  bottom: 0;
  left: 0;
  border-width: 0 0 3px 3px;
}
#modal-bucket-scan .bucket-scan-frame__c--br {
  bottom: 0;
  right: 0;
  border-width: 0 3px 3px 0;
}
#modal-bucket-scan .bucket-scan-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 3;
}
#modal-bucket-scan .bucket-scan-flash--ok { background: rgba(5, 150, 105, 0.35); }
#modal-bucket-scan .bucket-scan-flash--warn { background: rgba(217, 119, 6, 0.35); }
#modal-bucket-scan .bucket-scan-flash--err { background: rgba(220, 38, 38, 0.35); }
#modal-bucket-scan .bucket-score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
#modal-bucket-scan .bucket-score-bar-fill {
  height: 100%;
  background: var(--acc2);
  border-radius: 999px;
  transition: width 0.2s ease;
  width: 0%;
}
#modal-bucket-scan .bucket-scanned-list {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 10px;
}

@media (max-width: 768px) {
  #modal-bucket-scan .bucket-scanned-list {
    max-height: clamp(80px, 22dvh, 140px);
  }
  #modal-bucket-scan .bucket-manual-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
  }
  #modal-bucket-scan .bucket-manual-row input {
    flex: 1 1 140px;
    min-height: 44px;
  }
  #modal-bucket-scan .bucket-manual-row .btn {
    min-height: 44px;
  }
}
#modal-bucket-scan .bucket-scanned-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
#modal-bucket-scan .bucket-scanned-row:last-child { border-bottom: none; }
#modal-bucket-scan .bucket-scanned-row--pulse {
  background: var(--goldL);
  border-radius: 6px;
  animation: bucketRowPulse 0.9s ease-out 2;
}
@keyframes bucketRowPulse {
  0%, 100% { background: var(--goldL); }
  50% { background: var(--gold); opacity: 0.35; }
}

/* ═══ Extended detail panel (transfer / request — not footer card) ═══ */
.cosmos-extended-detail__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--cosmos-z-detail-backdrop, 240);
  background: rgba(15, 23, 42, 0.45);
  -webkit-tap-highlight-color: transparent;
}
.cosmos-extended-detail__backdrop.is-open {
  display: block;
}
.cosmos-extended-detail__panel {
  display: none;
  position: fixed;
  z-index: var(--cosmos-z-detail-panel, 250);
  flex-direction: column;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  overflow: hidden;
  min-height: 0;
}
.cosmos-extended-detail__panel.is-open {
  display: flex;
}
body.cosmos-extended-detail-open {
  overflow: hidden;
}
.cosmos-extended-detail__toolbar {
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cosmos-extended-detail__toolbar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.cosmos-extended-detail__toolbar-top .cosmos-extended-detail__head {
  flex: 1;
  min-width: 0;
}
.cosmos-extended-detail__close {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: -4px -4px 0 0;
  border: none;
  border-radius: 8px;
  line-height: 1;
  color: var(--text2, #64748b);
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cosmos-extended-detail__close:hover,
.cosmos-extended-detail__close:focus-visible {
  background: var(--border, #e2e8f0);
  color: var(--text1, #0f172a);
  outline: none;
}
.cosmos-extended-detail__head {
  min-width: 0;
}
.cosmos-extended-detail__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1, #0f172a);
  line-height: 1.35;
  word-break: break-word;
}
.cosmos-extended-detail__meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text2, #64748b);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.cosmos-extended-detail__actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.cosmos-extended-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}
.cosmos-extended-detail__actions .btn {
  min-height: 44px;
}
.cosmos-extended-detail__msg {
  flex-shrink: 0;
  padding: 0 16px 8px;
  font-size: 12px;
  min-height: 0;
}
.cosmos-extended-detail__msg:not(:empty) {
  min-height: 16px;
}
.cosmos-extended-detail__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cosmos-extended-detail__chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.cosmos-extended-detail__chip label {
  display: block;
  font-size: 11px;
  color: var(--text3, #94a3b8);
  margin-bottom: 2px;
}
.cosmos-extended-detail__chip span {
  font-size: 13px;
  color: var(--text1, #0f172a);
}
@media (max-width: 768px) {
  .cosmos-extended-detail__panel.is-open {
    left: 0;
    right: 0;
    bottom: 0;
    top: max(52px, env(safe-area-inset-top, 0px));
    max-height: min(96dvh, calc(var(--cosmos-vvh, 100dvh) * 0.96));
    border-radius: 16px 16px 0 0;
    width: auto;
  }
}
@media (min-width: 769px) {
  .cosmos-extended-detail__panel.is-open {
    top: 72px;
    right: 16px;
    bottom: 16px;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100dvh - 88px);
    border-radius: 12px;
  }
}

/* ═══ Record list module (Incoming-style rows + filter chips) ═══ */
body.cosmos-app-shell .cosmos-page-head {
  flex-shrink: 0;
  background: var(--card, #fff);
  z-index: 2;
}
.cosmos-page-filters,
.sp-page-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.cosmos-page-filters .btn.sm,
.sp-page-filters .btn.sm,
.ftr-status-tabs .btn.sm {
  flex-shrink: 0;
  min-height: 44px;
  touch-action: manipulation;
}
.cosmos-page-filters .btn.sm.active,
.sp-page-filters .btn.sm.active,
.ftr-status-tabs .btn.sm.active {
  background: var(--accL, #e8f4ff);
  border-color: var(--acc2, #2b8cff);
  color: var(--acc, #1d6fd4);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--acc2, #2b8cff);
}
.cosmos-record-list {
  display: flex;
  flex-direction: column;
}
.cosmos-record-row,
.inc-tr-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  min-height: 56px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.cosmos-record-row:last-child,
.inc-tr-row:last-child {
  border-bottom: none;
}
.cosmos-record-row:hover,
.cosmos-record-row:focus-visible,
.inc-tr-row:hover,
.inc-tr-row:focus-visible {
  background: var(--accL, #e8f4ff);
  outline: none;
}
.cosmos-record-row__main,
.inc-tr-meta {
  flex: 1;
  min-width: 0;
}
.cosmos-record-row__primary,
.inc-tr-id {
  font-size: 14px;
  font-weight: 700;
  color: var(--acc2, #2b8cff);
  line-height: 1.35;
}
.cosmos-record-row__secondary,
.inc-tr-sub {
  font-size: 12px;
  color: var(--text2, #64748b);
  margin-top: 3px;
  line-height: 1.4;
}
.cosmos-record-row__progress {
  font-size: 12px;
  color: var(--text2, #64748b);
  margin-top: 4px;
}
.cosmos-record-row__progress-rem {
  color: var(--gold, #d97706);
  font-weight: 600;
}
.cosmos-record-row__badge {
  flex-shrink: 0;
}
.cosmos-detail-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
}
.cosmos-detail-table-wrap table {
  min-width: 520px;
}
.cosmos-detail-qty-bar {
  font-size: 13px;
  color: var(--text2, #64748b);
  margin-bottom: 14px;
  line-height: 1.5;
}
.cosmos-detail-qty-bar strong {
  color: var(--text1, #0f172a);
}
@media (max-width: 768px) {
  body.cosmos-app-shell .cosmos-page-head {
    position: sticky;
    top: 0;
  }
  .cosmos-page-filters,
  .sp-page-filters,
  .ftr-status-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .cosmos-extended-detail__actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .cosmos-extended-detail__actions {
    width: 100%;
  }
  .cosmos-extended-detail__actions .btn.primary {
    width: 100%;
    justify-content: center;
  }
}
@media (min-width: 769px) {
  #page-transfer-requests .ftr-request-list-mobile {
    display: none !important;
  }
}
@media (max-width: 768px) {
  #page-transfer-requests .ftr-request-cards--desktop {
    display: none !important;
  }
  #page-transfer-requests .ftr-request-list-mobile {
    display: block;
  }
}

/* ── PWA app update popup (cosmos-pwa-update.js) ─────────────────────────── */
.cosmos-pwa-update-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 12000;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(15, 23, 42, 0.58);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .cosmos-pwa-update-overlay {
    background: rgba(15, 23, 42, 0.52);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

.cosmos-pwa-update-overlay.open {
  display: flex;
}

.cosmos-pwa-update-modal {
  width: min(400px, calc(100vw - 32px));
  max-width: 100%;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.cosmos-pwa-update-body {
  padding: 24px 24px 8px;
  text-align: center;
}

.cosmos-pwa-update-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accL, #eff6ff);
  color: var(--acc2, #1d4ed8);
}

.cosmos-pwa-update-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text1, #0f172a);
  line-height: 1.25;
}

.cosmos-pwa-update-sub {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text2, #475569);
}

.cosmos-pwa-update-version {
  margin: 10px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text3, #64748b);
}

.cosmos-pwa-update-actions {
  display: flex;
  gap: 10px;
  padding: 16px 24px 24px;
}

.cosmos-pwa-update-actions .btn {
  flex: 1;
  min-height: 44px;
}

body.cosmos-pwa-update-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .cosmos-pwa-update-modal {
    width: 100%;
    border-radius: 16px 16px 0 0;
    margin-top: auto;
  }

  .cosmos-pwa-update-overlay.open {
    align-items: flex-end;
    padding: 0;
  }
}

/* GatePass FAB — long-press vertical reposition */
#pos-gp-fab-root,
#sp-gp-fab-root,
#cx-gp-fab-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9000;
  align-items: flex-end;
  touch-action: none;
  max-width: calc(100vw - 32px);
}
@media (max-width: 640px) {
  #pos-gp-fab-root,
  #sp-gp-fab-root,
  #cx-gp-fab-root {
    right: 16px;
  }
}
#pos-gp-fab-root:not([hidden]),
#sp-gp-fab-root:not([hidden]),
#cx-gp-fab-root:not([hidden]) {
  display: flex;
  flex-direction: column-reverse;
}
.cosmos-gp-fab--dragging {
  cursor: grabbing !important;
  touch-action: none;
  user-select: none;
}
.cosmos-gp-fab--dragging:hover {
  transform: none !important;
}

/* Panel uses fixed coords while open (set in JS) — works on all viewport sizes */
.sp-gp-fab-panel.cosmos-gp-fab-panel--fixed,
.pos-gp-fab-panel.cosmos-gp-fab-panel--fixed {
  position: fixed;
  z-index: 1101;
  margin: 0;
  width: min(340px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
}
.sp-gp-fab-panel.cosmos-gp-fab-panel--fit,
.pos-gp-fab-panel.cosmos-gp-fab-panel--fit {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sp-gp-fab-panel.cosmos-gp-fab-panel--fit .sp-gp-contacts-container,
.sp-gp-fab-panel.cosmos-gp-fab-panel--fit #sp-gp-contacts-container,
.sp-gp-fab-panel.cosmos-gp-fab-panel--fit #pos-gp-contacts-container,
.sp-gp-fab-panel.cosmos-gp-fab-panel--fit #cx-gp-contacts-container,
.pos-gp-fab-panel.cosmos-gp-fab-panel--fit .pos-gp-contacts-container,
.pos-gp-fab-panel.cosmos-gp-fab-panel--fit #pos-gp-contacts-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Data grid column filters (Excel-style) ── */
.cosmos-data-grid-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: min(70vh, 640px);
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.cosmos-data-grid-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card, #fff);
  box-shadow: 0 1px 0 var(--border, #e2e8f0);
}
.cosmos-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}
.cosmos-col-label {
  font-size: inherit;
  font-weight: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cosmos-col-sort {
  color: var(--acc2, #1e40af);
  font-weight: 700;
}
.cosmos-col-filter-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text3, #94a3b8);
  cursor: pointer;
}
.cosmos-col-filter-btn:hover {
  background: var(--accL, #eff6ff);
  color: var(--acc2, #1e40af);
  border-color: var(--border, #e2e8f0);
}
.cosmos-col-filter-btn.is-active {
  background: var(--accL, #eff6ff);
  color: var(--acc2, #1e40af);
  border-color: var(--acc, #2563eb);
}
#cosmos-col-filter-popover {
  position: fixed;
  z-index: 1200;
  width: 240px;
  max-width: calc(100vw - 16px);
}
#cosmos-col-filter-popover[hidden] {
  display: none !important;
}
.cosmos-col-filter-popover-inner {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cosmos-col-filter-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cosmos-col-filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text3, #64748b);
}
.cosmos-col-filter-sort-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cosmos-col-filter-search {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: var(--bg, #f8fafc);
  color: var(--text1, #0f172a);
}
.cosmos-col-filter-actions-row {
  display: flex;
  gap: 6px;
}
.cosmos-col-filter-values {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
}
.cosmos-col-filter-check {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--text2, #334155);
  cursor: pointer;
  padding: 2px 0;
}
.cosmos-col-filter-check span {
  word-break: break-word;
}
.cosmos-col-filter-empty {
  font-size: 12px;
  color: var(--text3, #94a3b8);
  padding: 8px 0;
}
.cosmos-col-filter-footer {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border, #e2e8f0);
}
.mc-clear-col-filters {
  font-size: 12px;
  color: var(--acc2, #1e40af);
  cursor: pointer;
  margin-left: 12px;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
}
.mc-clear-col-filters:hover {
  color: var(--acc, #2563eb);
}
