@keyframes cosmosShimmer {
  0% { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}

/*
  Global: .btn { display:inline-flex } beats the UA [hidden] rule.
  Lifecycle / RBAC hide (el.hidden = true) must actually remove the control.
  See .cursor/rules/lifecycle-button-schedule.mdc + rbac-hide-not-disable.mdc
*/
.btn[hidden],
button.btn[hidden],
a.btn[hidden] {
  display: none !important;
}

/*
  Toolbar / filter / shell chrome: author display:flex|inline-flex also beats UA [hidden].
  Keep [hidden] as the single hide API for RBAC + page-scoped filters across modules.
*/
.fgrp[hidden],
.fin-page-filters[hidden],
.pc-page-filters[hidden],
.cosmos-page-filters[hidden],
.sp-page-filters[hidden],
.analyst-filter-bar[hidden],
.analyst-filter-presets[hidden],
.analyst-period-wrap[hidden],
.analyst-store-trigger[hidden],
.analyst-category-trigger[hidden],
.owner-store-trigger[hidden],
.talk-inbox-store-filter[hidden],
.cosmos-tab[hidden],
.cosmos-btab[hidden],
.cosmos-more-item[hidden],
.csc-page-head-picker[hidden],
.csc-page-head-drill[hidden] {
  display: none !important;
}

/* INR + emoji — self-hosted subsets (see /css/fonts.css); polish loads before fonts.css on some shells */
@font-face {
  font-family: 'Cosmos INR';
  src: url('/fonts/cosmos-inr.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+20B9;
}

.cosmos-inr-sign {
  font-family: 'Cosmos INR', var(--font-sans, 'Inter', system-ui, sans-serif);
  font-weight: inherit;
  display: inline-block;
  line-height: 1;
  min-width: 0.55em;
  text-align: center;
}

.cosmos-emoji {
  font-family: 'Cosmos Emoji', var(--font-sans, 'Inter', system-ui, sans-serif);
  font-style: normal;
  font-weight: inherit;
  line-height: 1;
  display: inline-block;
}

/* iPad / iOS Safari — unicode-range on Inter is unreliable; force dedicated webfonts on spans */
@supports (-webkit-touch-callout: none) {
  .cosmos-inr-sign {
    font-family: 'Cosmos INR', sans-serif !important;
  }
  .cosmos-emoji {
    font-family: 'Cosmos Emoji', sans-serif !important;
  }
}

.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;
}

/* ═══════════════════════════════════════════════════════════════════════════
   App-wide text selection — native-app feel; forms stay selectable
   ═══════════════════════════════════════════════════════════════════════════ */
html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
select,
option,
[contenteditable='true'],
.cosmos-selectable,
.cosmos-selectable * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

@media print {
  html,
  body {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }
}

@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 var(--border, #e2e8f0);
  border-top-color: var(--acc2, #2563eb);
  border-radius: 50%;
  animation: cosmosSpin 0.65s linear infinite;
}

.btn.primary.btn-loading::after {
  border-color: rgba(255, 255, 255, 0.35);
  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-msg {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cosmos-toast.toast-error {
  max-width: min(440px, calc(100vw - 32px));
}

.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) {
  /* Tall modals — fixed chrome, scrollable body (matches mobile overlay rules) */
  .overlay.open .modal:has(.modal-body, .mb, .bucket-modal-body) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: min(90vh, 90dvh);
  }
  .overlay.open .modal .modal-header,
  .overlay.open .modal .mh,
  .overlay.open .modal .modal-footer,
  .overlay.open .modal .mf {
    flex-shrink: 0;
  }
  .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;
  }

  .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;
  }

  /* StorePilot create-request footer only — FTR uses unified stacked foot */
  #overlay-sp-create-request .sp-create-request-foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  #overlay-sp-create-request .sp-create-request-msg {
    flex: 1 1 auto;
    max-width: 50%;
  }
  #overlay-sp-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: var(--font-mono);
}

@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;
  }

  .modal.modal--create-request .sp-create-request-grabber {
    display: block;
  }
}

/* Foundry create transfer — unified stacked sheet (phone + desktop) */
#overlay-ftr-create-transfer.overlay.open {
  overscroll-behavior: contain;
}

#overlay-ftr-create-transfer.overlay.open .modal.modal--create-request {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#overlay-ftr-create-transfer .sp-create-request-grabber {
  display: block;
}

#overlay-ftr-create-transfer .sp-create-request-head {
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

#overlay-ftr-create-transfer .ftr-ct-subtitle,
#overlay-ftr-create-transfer .sp-create-request-store-line.ftr-ct-subtitle {
  display: block;
  font-size: 12px;
  margin-top: 4px;
  color: var(--text2, #64748b);
}

#overlay-ftr-create-transfer .ftr-ct-desktop-blurb {
  display: none !important;
}

#overlay-ftr-create-transfer .ftr-ct-cart-strip {
  display: flex;
}

#overlay-ftr-create-transfer .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-ftr-create-transfer .sp-create-request-layout,
#overlay-ftr-create-transfer .ftr-ct-layout {
  display: flex !important;
  flex-direction: column;
  grid-template-columns: none !important;
  gap: 0;
  min-height: min-content;
}

#overlay-ftr-create-transfer .ftr-ct-search-block {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
  flex-shrink: 0;
}

#overlay-ftr-create-transfer .sp-create-request-search-card {
  background: transparent;
  border: none;
  box-shadow: none;
  margin: 0;
  border-radius: 0;
  padding: 0 !important;
}

#overlay-ftr-create-transfer .sp-create-request-search-input {
  min-height: 44px;
  font-size: 16px;
}

#overlay-ftr-create-transfer .csc-shell--compact .csc-results-wrap {
  max-height: none;
}

#overlay-ftr-create-transfer .csc-shell--compact .pos-catalogue-results {
  grid-template-columns: 1fr !important;
  gap: 10px;
  padding: 8px 0 16px;
}

#overlay-ftr-create-transfer .sp-create-request-cart-col {
  padding: 12px 16px 16px;
  background: var(--bg, #f8fafc);
}

#overlay-ftr-create-transfer .sp-create-request-cart-card,
#overlay-ftr-create-transfer .sp-create-request-meta-card {
  margin-bottom: 12px;
  border-radius: 12px;
}

#overlay-ftr-create-transfer .sp-create-request-cart-card:last-child,
#overlay-ftr-create-transfer .sp-create-request-meta-card {
  margin-bottom: 0;
}

#overlay-ftr-create-transfer .sp-create-request-notes,
#overlay-ftr-create-transfer #ftr-ct-store-sel {
  font-size: 16px;
  min-height: 44px;
}

#overlay-ftr-create-transfer .sp-create-request-foot {
  flex-direction: column;
  align-items: stretch;
  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-ftr-create-transfer .sp-create-request-msg {
  max-width: none;
  flex: none;
}

#overlay-ftr-create-transfer .sp-create-request-foot-btns {
  flex-direction: column;
  width: 100%;
  margin: 0;
  gap: 8px;
}

#overlay-ftr-create-transfer .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-ftr-create-transfer .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;
}

@media (max-width: 768px) {
  #overlay-ftr-create-transfer.overlay.open {
    align-items: flex-end;
    padding: 0;
  }

  #overlay-ftr-create-transfer.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);
  }

  #overlay-ftr-create-transfer .sp-create-request-head {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
  }

  @media (prefers-reduced-motion: reduce) {
    #overlay-ftr-create-transfer.overlay.open .modal.modal--create-request {
      animation: none;
    }
  }
}

@media (min-width: 769px) {
  #overlay-ftr-create-transfer.overlay.open {
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  #overlay-ftr-create-transfer.overlay.open .modal.modal--create-request {
    width: 100% !important;
    max-width: 520px !important;
    height: min(720px, calc(var(--cosmos-vvh, 100dvh) * 0.88));
    max-height: min(720px, calc(var(--cosmos-vvh, 100dvh) * 0.88)) !important;
    border-radius: 16px;
    margin: 0;
    animation: none;
  }

  #overlay-ftr-create-transfer .sp-create-request-grabber {
    display: none;
  }
}

/* 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: var(--font-sans);
  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;
}

input.cosmos-date-range-picker,
input.cosmos-date-range-picker.flatpickr-input,
input.cosmos-month-period-picker {
  min-height: 40px;
  min-width: 240px;
  cursor: pointer;
}

.cosmos-month-period-popover {
  width: 280px;
  padding: 12px;
  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);
  display: block;
  position: fixed;
  z-index: 10060;
}

.cosmos-month-period-popover[hidden] {
  display: none !important;
}

.cosmos-month-period-popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cosmos-month-period-popover__year {
  font-size: 15px;
  font-weight: 600;
  color: var(--text1, #0f172a);
}

.cosmos-month-period-popover__nav {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text2, #64748b);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.cosmos-month-period-popover__nav:hover {
  background: var(--accL, #eff6ff);
  color: var(--acc2, #1d4ed8);
}

.cosmos-month-period-popover__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.cosmos-month-period-popover__month {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--text1, #0f172a);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.cosmos-month-period-popover__month:hover {
  background: var(--accL, #eff6ff);
  color: var(--acc2, #1d4ed8);
}

.cosmos-month-period-popover__month.selected {
  background: var(--acc, #2563eb);
  border-color: var(--acc, #2563eb);
  color: #fff;
}

.cosmos-month-period-popover__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border, #e2e8f0);
}

.cosmos-month-period-popover__footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cosmos-month-period-popover__action {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm, 6px);
}

.cosmos-month-period-popover__action--muted {
  color: var(--text2, #64748b);
}

.cosmos-month-period-popover__action--custom {
  color: var(--acc2, #1d4ed8);
}

.cosmos-month-period-popover__action--primary {
  color: var(--acc2, #1d4ed8);
}

.cosmos-month-period-popover__action:hover {
  background: var(--accL, #eff6ff);
}

.cosmos-flatpickr-range-footer {
  margin-top: 8px;
  justify-content: flex-end;
}

.flatpickr-calendar.cosmos-flatpickr--range .flatpickr-day.inRange {
  background: var(--accL, #eff6ff);
  border-color: transparent;
  box-shadow: -5px 0 0 var(--accL, #eff6ff), 5px 0 0 var(--accL, #eff6ff);
  color: var(--text1, #0f172a);
}

.flatpickr-calendar.cosmos-flatpickr--range .flatpickr-day.startRange,
.flatpickr-calendar.cosmos-flatpickr--range .flatpickr-day.endRange,
.flatpickr-calendar.cosmos-flatpickr--range .flatpickr-day.startRange:hover,
.flatpickr-calendar.cosmos-flatpickr--range .flatpickr-day.endRange: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;
}

/* Inner scroll region — paired with :has(.sp-page-body) shell rules above */
body.cosmos-app-shell .sp-page-head {
  flex-shrink: 0;
}

body.cosmos-app-shell .sp-page-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* 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;
}

/* Hub shortcut — transparent SVG asset (`/img/hub-icon.svg`) in every shell */
.cosmos-hub-shortcut-icon {
  display: block;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  object-fit: contain;
  pointer-events: none;
}

.cosmos-module-hub-link .cosmos-hub-shortcut-icon {
  width: 28px;
  height: 28px;
}

.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: var(--font-sans);
  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: var(--font-sans);
  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-top: 14px;
    padding-right: 14px;
    padding-left: 14px;
    /* Do NOT use padding shorthand — it zeros padding-bottom and overlaps .cosmos-bottom-tabs.
       Clearance comes from cosmos-ios-shell.css when body.cosmos-has-ios-shell. */
    padding-bottom: var(--cosmos-ios-content-bottom-clearance, 14px);
  }
  body.cosmos-app-shell:not(.cosmos-has-ios-shell) .cosmos-app-scroll .page {
    padding-bottom: 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-od-modal-title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2, 8px);
  min-width: 0;
  padding-right: var(--space-2, 8px);
}
.cosmos-od-modal-title-lbl {
  font-size: var(--font-size-base, 15px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text1, #0f172a);
  white-space: nowrap;
}
.cosmos-od-modal-title-id {
  font-size: var(--font-size-sm, 12px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text2, #475569);
  letter-spacing: 0.01em;
}
.cosmos-od-booking-status {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-2, 8px);
}
.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;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}
.cosmos-order-detail-modal .cosmos-timeline-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.cosmos-od-modal-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border, #e2e8f0);
  padding: 12px 16px 16px;
  background: var(--card, #fff);
}
.cosmos-od-footer-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cosmos-od-footer-note {
  font-size: 12px;
  color: var(--text2, #475569);
  margin: 0;
  line-height: 1.45;
}
.cosmos-od-hold-btn {
  width: 100%;
  min-height: var(--tap-target-mobile, 44px);
}
.cosmos-od-section--context {
  border-color: var(--acc, #2563eb);
  background: var(--accL, #eff6ff);
}
.cosmos-od-chip--context {
  background: var(--acc, #2563eb);
  color: var(--card, #fff);
}
.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-section--order-image .cosmos-od-photo-btn {
  min-height: var(--tap-target-desktop, 36px);
}
/* Shared lab photo links — Foundry loads cosmos-ui-polish.css, not crew-lab-mobile.css */
.fy-lab-card__photo-link,
button.fy-lab-card__photo-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--acc2);
  margin-top: var(--space-1, 4px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accL);
  border: 1px solid var(--acc);
  border-radius: var(--radius-md, 8px);
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  min-height: var(--tap-target-desktop, 36px);
}
.fy-lab-card__photo-link:hover,
button.fy-lab-card__photo-link:hover {
  color: var(--acc);
  background: var(--card);
}
.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; }
/* Booking detail payment — vertical ledger (subtotal → offer → advance → due) */
.cosmos-od-pay-ledger {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cosmos-od-pay-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-1, 4px) var(--space-3, 12px);
  align-items: start;
  padding: var(--space-3, 12px) 0;
  border-bottom: 1px solid var(--border, #e2e8f0);
  margin: 0;
}
.cosmos-od-pay-line:last-child { border-bottom: none; padding-bottom: 0; }
.cosmos-od-pay-line:first-child { padding-top: 0; }
.cosmos-od-pay-line-lbl {
  margin: 0;
  font-size: var(--font-size-sm, 12px);
  font-weight: var(--font-weight-semibold, 600);
  color: var(--text1, #0f172a);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cosmos-od-pay-line-hint {
  font-size: var(--font-size-xs, 10px);
  font-weight: var(--font-weight-normal, 400);
  color: var(--text3, #64748b);
  line-height: 1.35;
}
.cosmos-od-pay-line-val {
  margin: 0;
  font-size: var(--font-size-md, 14px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--text1, #0f172a);
  text-align: right;
  white-space: nowrap;
}
.cosmos-od-pay-line--offer .cosmos-od-pay-line-lbl { color: var(--green, #059669); }
.cosmos-od-pay-line--payable {
  background: var(--bg, #f8fafc);
  margin: 0 calc(-1 * var(--space-1, 4px));
  padding-left: var(--space-1, 4px);
  padding-right: var(--space-1, 4px);
  border-bottom-color: var(--border, #e2e8f0);
}
.cosmos-od-pay-line--payable .cosmos-od-pay-line-val {
  font-size: var(--font-size-lg, 16px);
  color: var(--acc2, #1d4ed8);
}
.cosmos-od-pay-line--due .cosmos-od-pay-line-val { font-size: var(--font-size-lg, 16px); }
.cosmos-od-pay-val--offer { color: var(--green, #059669); }
.cosmos-od-pay-val--due { color: var(--gold, #b45309); }
/* Compact booking-detail payment (CREW long-press modal) */
.cosmos-od-pay-summary--compact {
  margin-bottom: var(--space-3, 12px);
  padding-top: var(--space-2, 8px);
  border-top: 1px solid var(--border, #e2e8f0);
}
.cosmos-od-pay-line--compact {
  padding: var(--space-2, 8px) 0;
  align-items: center;
}
.cosmos-od-pay-line--compact .cosmos-od-pay-line-lbl {
  font-size: var(--font-size-md, 14px);
  font-weight: var(--font-weight-normal, 400);
  color: var(--text2, #475569);
  flex-direction: row;
}
.cosmos-od-pay-line--compact.cosmos-od-pay-line--offer .cosmos-od-pay-line-lbl {
  color: var(--green, #059669);
  font-weight: var(--font-weight-medium, 500);
}
.cosmos-od-pay-line--compact .cosmos-od-pay-line-val {
  font-size: var(--font-size-md, 14px);
  font-weight: var(--font-weight-semibold, 600);
}
.cosmos-od-pay-line--compact.cosmos-od-pay-line--payable {
  background: transparent;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  border-top: 1px solid var(--border, #e2e8f0);
  margin-top: var(--space-1, 4px);
  padding-top: var(--space-3, 12px);
}
.cosmos-od-pay-line--compact.cosmos-od-pay-line--payable .cosmos-od-pay-line-lbl {
  font-weight: var(--font-weight-bold, 700);
  color: var(--text1, #0f172a);
}
.cosmos-od-pay-line--compact.cosmos-od-pay-line--payable .cosmos-od-pay-line-val {
  font-size: var(--font-size-lg, 16px);
  font-weight: var(--font-weight-bold, 700);
  color: var(--acc2, #1d4ed8);
}
.cosmos-od-pay-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3, 12px);
  padding-top: var(--space-2, 8px);
  font-size: var(--font-size-sm, 12px);
  color: var(--text2, #475569);
}
.cosmos-od-pay-split-item strong {
  font-weight: var(--font-weight-bold, 700);
  color: var(--text1, #0f172a);
}
.cosmos-od-rx {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border, #e2e8f0);
}
.cosmos-od-rx .cosmos-lab-rx-table { margin-top: 8px; }
.cosmos-od-chip--pending {
  background: var(--goldL, #fef3c7);
  color: var(--gold, #92400e);
}
.cosmos-od-share-btn {
  width: 100%;
  min-height: var(--tap-target-mobile, 44px);
}
[data-order-id].tr-link { cursor: pointer; }
[data-order-id].tr-link,
[data-order-id].tr-link * {
  -webkit-touch-callout: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   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;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}
#modal-bucket-scan #bucket-video.is-live {
  opacity: 1;
}
#modal-bucket-scan .bucket-scan-viewport {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 10px;
  background: #000;
  border: 1px solid var(--border);
  touch-action: manipulation;
}
#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-stock-progress,
.cosmos-record-row-content-row {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.35;
}
.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)) {
  .cosmos-pwa-update-overlay {
    background: rgba(15, 23, 42, 0.52);
    -webkit-backdrop-filter: blur(4px);
  }
}

@supports (backdrop-filter: blur(1px)) {
  .cosmos-pwa-update-overlay {
    background: rgba(15, 23, 42, 0.52);
    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;
}

.cosmos-pwa-update-icon--busy::after {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--accL, #eff6ff);
  border-top-color: var(--acc2, #1d4ed8);
  border-radius: 50%;
  animation: cosmos-pwa-update-spin 0.75s linear infinite;
}

@keyframes cosmos-pwa-update-spin {
  to { transform: rotate(360deg); }
}

.cosmos-pwa-update-overlay.open[aria-busy="true"] .cosmos-pwa-update-modal {
  pointer-events: none;
}

.cosmos-pwa-update-overlay--prompt .cosmos-pwa-update-icon {
  font-size: 28px;
  line-height: 56px;
  color: var(--acc2, #1d4ed8);
  background: var(--accL, #eff6ff);
}

.cosmos-pwa-update-overlay--prompt.open .cosmos-pwa-update-modal {
  pointer-events: auto;
}

  body.cosmos-pwa-update-open {
  overflow: hidden;
}

/* ── PWA icon update banner + reinstall sheet (hub-pwa.js) ───────────────── */
.cosmos-pwa-icon-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9600;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md, 12px);
  background: var(--navy, #0B1F33);
  color: #fff;
  box-shadow: 0 8px 28px rgba(11, 31, 51, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

body.cosmos-has-ios-shell .cosmos-pwa-icon-banner {
  bottom: calc(
    var(--cosmos-ios-tab-bar-height, 64px)
    + var(--cosmos-ios-tab-bar-float, 12px)
    + env(safe-area-inset-bottom, 0px)
    + 8px
  );
}

.cosmos-pwa-icon-banner[hidden] {
  display: none !important;
}

body.cosmos-pwa-icon-banner-open {
  --cosmos-pwa-icon-banner-clearance: 88px;
}

body.cosmos-has-ios-shell.cosmos-pwa-icon-banner-open .page {
  padding-bottom: calc(
    var(--cosmos-ios-content-bottom-clearance, 80px)
    + var(--cosmos-pwa-icon-banner-clearance, 88px)
  ) !important;
}

.cosmos-pwa-icon-banner__icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

.cosmos-pwa-icon-banner__body {
  flex: 1 1 auto;
  min-width: 0;
}

.cosmos-pwa-icon-banner__title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.cosmos-pwa-icon-banner__sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
  margin-top: 2px;
}

.cosmos-pwa-icon-banner__cta {
  flex-shrink: 0;
  min-height: var(--tap-target-mobile, 44px);
  white-space: nowrap;
}

.cosmos-pwa-icon-banner__dismiss {
  flex-shrink: 0;
  min-height: var(--tap-target-mobile, 44px);
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.25);
  background: transparent;
}

/* Icon reinstall sheet — self-contained overlay (Hub has no module .overlay base) */
#cosmos-pwa-icon-sheet.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9800;
  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(11, 31, 51, 0.45);
}

#cosmos-pwa-icon-sheet.overlay[hidden] {
  display: none !important;
}

#cosmos-pwa-icon-sheet.overlay.open {
  display: flex;
}

body.cosmos-pwa-icon-sheet-open {
  overflow: hidden;
}

#cosmos-pwa-icon-sheet .modal.cosmos-pwa-icon-sheet-modal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: min(420px, 100%);
  max-height: min(90dvh, 90vh);
  background: var(--card, #fff);
  border-radius: var(--radius-md, 14px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

#cosmos-pwa-icon-sheet .modal-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  flex-shrink: 0;
}

#cosmos-pwa-icon-sheet .modal-h h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text1, #0f172a);
  line-height: 1.3;
}

#cosmos-pwa-icon-sheet .modal-b {
  padding: 16px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}

.cosmos-pwa-icon-sheet-modal {
  max-width: 420px;
}

.cosmos-pwa-icon-sheet-lead {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text2);
  margin-bottom: 14px;
}

.cosmos-pwa-icon-sheet-steps {
  margin: 0 0 16px 1.1rem;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text1);
}

.cosmos-pwa-icon-sheet-steps li + li {
  margin-top: 8px;
}

.cosmos-pwa-icon-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.cosmos-pwa-icon-sheet-actions .btn {
  min-height: var(--tap-target-mobile, 44px);
}

@media (max-width: 768px) {
  .cosmos-pwa-icon-banner {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .cosmos-pwa-icon-banner__cta,
  .cosmos-pwa-icon-banner__dismiss {
    flex: 1 1 calc(50% - 4px);
  }

  #cosmos-pwa-icon-sheet.overlay {
    align-items: flex-end;
    padding: 0;
  }

  #cosmos-pwa-icon-sheet.overlay.open .modal.cosmos-pwa-icon-sheet-modal {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 92vh);
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .cosmos-pwa-icon-sheet-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cosmos-pwa-icon-sheet-actions .btn {
    width: 100%;
  }
}

@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;
}
button.cosmos-col-sort-btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  max-width: 100%;
}
button.cosmos-col-sort-btn:hover {
  color: var(--acc2, #1e40af);
}
.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: max-content;
  min-width: 240px;
  max-width: min(360px, 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: 8px;
  font-size: 12px;
  color: var(--text2, #334155);
  cursor: pointer;
  padding: 2px 0;
}
/* Foundry/CU set input { width:100%; padding }, which stretched this checkbox and crushed the label. */
.cosmos-col-filter-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  flex: 0 0 16px;
  margin: 1px 0 0;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  accent-color: var(--acc, #2563eb);
}
.cosmos-col-filter-check span {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: 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);
}

.mc-grid-edit-toolbar .btn[hidden] {
  display: none !important;
}
/* Cosmos Excel Grid — shared select / active / editing (Master Catalogue + callers) */
.cosmos-excel-cell,
#page-master-catalogue .mc-grid-edit-cell {
  position: relative;
  min-width: 88px;
  max-width: 180px;
  cursor: cell;
  user-select: none;
  vertical-align: middle;
}
.cosmos-excel-cell-display,
#page-master-catalogue .mc-grid-cell-display {
  display: block;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text1, #0f172a);
  padding: 4px 6px;
  min-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cosmos-excel-cell input,
.cosmos-excel-cell select,
#page-master-catalogue .mc-grid-edit-cell input,
#page-master-catalogue .mc-grid-edit-cell select {
  width: 100%;
  min-width: 72px;
  max-width: 160px;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
  user-select: text;
}
td.cosmos-excel-cell-selected,
#page-master-catalogue td.mc-grid-cell-selected {
  background: var(--accL, #eff6ff);
  outline: 1px solid var(--acc, #2563eb);
  outline-offset: -1px;
}
td.cosmos-excel-cell-active,
#page-master-catalogue td.mc-grid-cell-active {
  outline: 2px solid var(--acc, #2563eb);
  outline-offset: -2px;
  z-index: 1;
}
td.cosmos-excel-cell-editing,
#page-master-catalogue td.mc-grid-cell-editing {
  outline: 2px solid var(--acc2, #1e40af);
  outline-offset: -2px;
  background: var(--card, #fff);
  cursor: text;
  user-select: text;
}
#page-master-catalogue td.mc-grid-cell-dirty {
  background: var(--accL, #eff6ff);
}
#page-master-catalogue td.mc-grid-cell-dirty.mc-grid-cell-selected,
#page-master-catalogue td.mc-grid-cell-dirty.cosmos-excel-cell-selected {
  background: var(--accL, #eff6ff);
}
#page-master-catalogue .mc-grid-cell-dirty .mc-grid-edit-input {
  border-color: var(--acc2, #1e40af);
  box-shadow: 0 0 0 1px var(--accL, #eff6ff);
}
.cosmos-excel-grid-selecting,
.cosmos-excel-grid-selecting .cosmos-excel-cell-display,
#page-master-catalogue .mc-grid-selecting,
#page-master-catalogue .mc-grid-selecting .mc-grid-cell-display {
  user-select: none;
  cursor: cell;
}
.np-invoice-pdf-table.cosmos-excel-grid .cosmos-excel-cell {
  max-width: none;
  min-width: 0;
}
.np-invoice-pdf-table.cosmos-excel-grid .cosmos-excel-cell input,
.np-invoice-pdf-table.cosmos-excel-grid .cosmos-excel-cell select {
  max-width: none;
  color: var(--text1, #0f172a);
  background: var(--card, #fff);
}
.np-invoice-pdf-table.cosmos-excel-grid td.cosmos-excel-cell-selected input,
.np-invoice-pdf-table.cosmos-excel-grid td.cosmos-excel-cell-active input,
.np-invoice-pdf-table.cosmos-excel-grid td.cosmos-excel-cell-editing input {
  color: var(--text1, #0f172a);
  background: var(--card, #fff);
}
.mc-grid-row-paste-range td.mc-grid-edit-cell {
  background: var(--accL, #eff6ff);
}
.mc-grid-row-error td {
  background: var(--redL, #fef2f2);
}
.mc-grid-row-error-msg {
  display: block;
  font-size: 11px;
  color: var(--red, #dc2626);
  margin-top: 2px;
  max-width: 120px;
  line-height: 1.3;
}

/* ── Photo modal ─────────────────────────────────────────────────────────── */
.cosmos-photo-overlay {
  display: none;
  position: fixed;
  inset: 0;
  /* Above order-detail / timeline overlay (9999); below toasts (10000+) and camera (9500 is lower) */
  z-index: 10050;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.cosmos-photo-overlay.open {
  display: flex;
}
.cosmos-photo-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
}
.cosmos-photo-box {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(96vw, 960px);
  max-height: 94vh;
}
.cosmos-photo-viewport {
  position: relative;
  overflow: hidden;
  touch-action: none;
  width: 100%;
  max-height: min(78vh, 720px);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md, 8px);
  background: rgba(0, 0, 0, 0.35);
  cursor: zoom-in;
}
.cosmos-photo-viewport.is-zoomed {
  cursor: grab;
}
.cosmos-photo-viewport.is-dragging {
  cursor: grabbing;
}
.cosmos-photo-img {
  display: block;
  max-width: 100%;
  max-height: min(78vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.cosmos-photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}
.cosmos-photo-zoom-btn {
  min-width: var(--tap-target-mobile, 44px);
  min-height: var(--tap-target-mobile, 44px);
  padding: 0 12px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.cosmos-photo-zoom-btn--text {
  font-size: 13px;
  font-weight: 600;
  padding: 0 14px;
}
.cosmos-photo-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}
.cosmos-photo-zoom-label {
  min-width: 52px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}
.cosmos-photo-hint {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  line-height: 1.35;
  max-width: 420px;
}
.cosmos-photo-close {
  position: absolute;
  top: -44px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.85;
  transition: opacity 0.15s;
  min-width: var(--tap-target-mobile, 44px);
  min-height: var(--tap-target-mobile, 44px);
}
.cosmos-photo-close:hover {
  opacity: 1;
}
.cosmos-photo-caption {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
}

/* ── In-app camera capture (shared — Customer Frame, etc.) ──
   Self-contained: POS (and other shells) do not load a global `.overlay`
   fixed-fullscreen rule, so this modal must own its own popup chrome. */
#modal-cosmos-camera-capture.cosmos-cam-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
  margin: 0;
  box-sizing: border-box;
  background: rgba(15, 30, 53, 0.62);
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  #modal-cosmos-camera-capture.cosmos-cam-overlay {
    background: rgba(15, 30, 53, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }
}

#modal-cosmos-camera-capture.cosmos-cam-overlay.open {
  display: flex;
}

#modal-cosmos-camera-capture .cosmos-cam-modal {
  max-width: 100%;
  width: 100%;
  margin: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 96dvh;
}

#modal-cosmos-camera-capture .cosmos-cam-body {
  padding: 0;
}

#modal-cosmos-camera-capture .cosmos-cam-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 58dvh;
  background: var(--navy);
  border-radius: var(--radius-md);
}

#modal-cosmos-camera-capture #cosmos-cam-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}

#modal-cosmos-camera-capture #cosmos-cam-video.is-mirrored {
  -webkit-transform: translateZ(0) scaleX(-1);
  transform: translateZ(0) scaleX(-1);
}

#modal-cosmos-camera-capture #cosmos-cam-video.is-live {
  opacity: 1;
}

#modal-cosmos-camera-capture .cosmos-cam-flip-btn {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 3;
  width: var(--tap-target-mobile);
  height: var(--tap-target-mobile);
  min-width: var(--tap-target-mobile);
  min-height: var(--tap-target-mobile);
  border-radius: var(--radius-full);
  border: none;
  background: var(--navy);
  color: var(--card);
  opacity: 0.75;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease-out);
}

#modal-cosmos-camera-capture .cosmos-cam-flip-btn:hover,
#modal-cosmos-camera-capture .cosmos-cam-flip-btn:focus-visible {
  opacity: 1;
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

#modal-cosmos-camera-capture .cosmos-cam-flip-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#modal-cosmos-camera-capture .cosmos-cam-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--navy);
  color: var(--card);
  font-size: var(--font-size-md);
  font-weight: 600;
  text-align: center;
  z-index: 2;
}

#modal-cosmos-camera-capture .cosmos-cam-loading[hidden] {
  display: none;
}

#modal-cosmos-camera-capture .cosmos-cam-loading-spinner {
  width: var(--space-8);
  height: var(--space-8);
  border: 3px solid color-mix(in srgb, var(--card) 25%, transparent);
  border-top-color: var(--acc);
  border-radius: var(--radius-full);
  animation: cosmosSpin 0.65s linear infinite;
}

#modal-cosmos-camera-capture .cosmos-cam-hint {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text2);
  line-height: 1.45;
}

#modal-cosmos-camera-capture .cosmos-cam-actions {
  display: flex;
  gap: var(--space-3);
}

#modal-cosmos-camera-capture .cosmos-cam-actions .btn {
  flex: 1;
  min-height: var(--tap-target-mobile);
}

#modal-cosmos-camera-capture.cosmos-cam-overlay:not(.open) #cosmos-cam-video {
  opacity: 0;
}

/* Store OS — landscape tablet: centered dialog (not phone bottom sheet) */
@media (orientation: landscape) {
  html.cosmos-force-landscape #modal-cosmos-camera-capture.cosmos-cam-overlay.open,
  html.cosmos-cam-active #modal-cosmos-camera-capture.cosmos-cam-overlay.open {
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
  }

  html.cosmos-force-landscape #modal-cosmos-camera-capture .cosmos-cam-modal,
  html.cosmos-cam-active #modal-cosmos-camera-capture .cosmos-cam-modal {
    width: min(720px, 92vw);
    max-width: min(720px, 92vw);
    border-radius: var(--radius-xl);
    max-height: min(92dvh, 640px);
  }

  html.cosmos-force-landscape #modal-cosmos-camera-capture .cosmos-cam-preview-wrap,
  html.cosmos-cam-active #modal-cosmos-camera-capture .cosmos-cam-preview-wrap {
    aspect-ratio: 4 / 3;
    max-height: min(52dvh, 420px);
  }
}

/* ─── Rx checked-by typeahead (hospital → optometrist) ─────────────────────── */
.cosmos-rxcb-wrap {
  grid-column: 1 / -1;
}

.cosmos-rxcb-field {
  position: relative;
}

.cosmos-rxcb-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-md);
}

.cosmos-rxcb-results[hidden] {
  display: none;
}

.cosmos-rxcb-result {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text1);
  font-size: var(--font-size-sm);
  text-align: left;
  cursor: pointer;
  min-height: var(--tap-target-mobile);
}

.cosmos-rxcb-result:last-child {
  border-bottom: none;
}

.cosmos-rxcb-result:hover,
.cosmos-rxcb-result:focus-visible {
  background: var(--accL);
  outline: none;
}

.cosmos-rxcb-result-add {
  color: var(--acc2);
  font-weight: 600;
}

.cosmos-rxcb-empty {
  padding: 10px 12px;
  font-size: var(--font-size-sm);
  color: var(--text2);
}

.cosmos-rxcb-hint {
  margin: 8px 0 0;
  font-size: var(--font-size-xs);
  color: var(--text3);
}

.cosmos-rxcb-summary {
  margin: 6px 0 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accD);
}

/* ── Profile sheet (long-press avatar — all shells) ── */
.cosmos-topnav-user > .cosmos-topnav-signout,
.cosmos-more-user-row > .cosmos-topnav-signout {
  display: none !important;
}

.cosmos-topnav-user.is-profile-pressing,
.cosmos-more-user-row.is-profile-pressing,
#hub-profile-trigger.is-profile-pressing,
.cosmos-topnav-mobile-signout.is-profile-pressing {
  opacity: 0.72;
}

.cosmos-topnav-av,
.cosmos-more-user-av,
.hub-avatar,
.cosmos-profile-sheet-avatar {
  overflow: hidden;
}

.cosmos-profile-av-img,
.hub-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cosmos-profile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.35);
  animation: cosmosOverlayIn 0.15s ease-out both;
}
.cosmos-profile-backdrop[hidden] {
  display: none !important;
}

.cosmos-profile-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1201;
  background: var(--card, #fff);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
  padding: 0 20px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: cosmosSheetUpProfile 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.cosmos-profile-sheet[hidden] {
  display: none !important;
}

@keyframes cosmosSheetUpProfile {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.cosmos-profile-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #D1D1D6;
  margin: 12px auto 18px;
}

.cosmos-profile-sheet-user {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.12);
  margin-bottom: 12px;
}

.cosmos-profile-sheet-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--acc, #007AFF), var(--acc2, #5AC8FA));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.cosmos-profile-sheet-meta {
  min-width: 0;
  flex: 1;
}

.cosmos-profile-sheet-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text1, #000);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cosmos-profile-sheet-role {
  font-size: 13px;
  color: var(--text3, #8E8E93);
  margin-top: 2px;
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cosmos-profile-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cosmos-profile-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  border: none;
  border-radius: 12px;
  background: var(--bg, #F2F2F7);
  color: var(--text1, #000);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.cosmos-profile-action:hover {
  background: rgba(0, 0, 0, 0.06);
}
.cosmos-profile-action--danger {
  color: var(--red, #FF3B30);
  background: var(--redL, rgba(255, 59, 48, 0.08));
}
.cosmos-profile-action--danger:hover {
  background: rgba(255, 59, 48, 0.14);
}

/* Permission help sheet — iOS (no broken app-settings: deep links) */
.cosmos-perm-help-sheet-modal {
  max-width: 420px;
}

.cosmos-perm-help-lead {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text2, #475569);
  margin: 0 0 14px;
}

.cosmos-perm-help-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cosmos-perm-help-steps li {
  font-size: 14px;
  line-height: 1.45;
  color: var(--text1, #0B1F35);
}

.cosmos-perm-help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Centralized Eyewoot logo (brand = store; APP_BRAND_LOGO_URL via bootstrap) ── */
.cosmos-brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cosmos-brand-logo {
  max-width: 200px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.cosmos-brand-module-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cosmos-module-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 7px;
}

.cosmos-module-icon:not([hidden]) + .cosmos-module-label,
.cosmos-module-icon:not([hidden]) + .army-brand-army {
  display: none;
}

.cosmos-brand-logo[hidden] + .cosmos-brand-wordmark,
.cosmos-brand-logo[hidden] + .cosmos-topnav-eyewoot-wordmark {
  display: inline;
}

/* ── Forced UI orientation (CSS remap — no warning overlay) ─────────────── */

/* Store OS: always present landscape UI; rotate when device is portrait */
@media (orientation: portrait) {
  html.cosmos-force-landscape {
    overflow: hidden;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
  }

  html.cosmos-force-landscape.cosmos-cam-active body {
    position: static;
    top: auto;
    left: auto;
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    transform: none;
    overflow: visible;
  }

  /* iPad PWA (incl. 6th gen): GPU layer on live camera video — avoids black preview in WKWebView */
  body.sos-pwa-ipad-cam #cosmos-cam-video,
  body.sos-pwa-ipad-cam #bucket-video {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  body.sos-pwa-ipad-cam #cosmos-cam-video.is-mirrored {
    -webkit-transform: translateZ(0) scaleX(-1);
    transform: translateZ(0) scaleX(-1);
  }

  html.cosmos-force-landscape body {
    position: fixed;
    top: 0;
    left: 100vw;
    width: 100vh;
    height: 100vw;
    min-width: 100vh;
    min-height: 100vw;
    max-width: 100vh;
    max-height: 100vw;
    transform: rotate(90deg);
    transform-origin: top left;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Hub + iOS shells: always present portrait UI; rotate when device is landscape */
@media (orientation: landscape) and (max-width: 1024px), (orientation: landscape) and (pointer: coarse) {
  html.cosmos-force-portrait {
    overflow: hidden;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
  }

  html.cosmos-force-portrait body:not(.army-landscape-ok) {
    position: fixed;
    top: 100vh;
    left: 0;
    width: 100vh;
    height: 100vw;
    min-width: 100vh;
    min-height: 100vw;
    max-width: 100vh;
    max-height: 100vw;
    transform: rotate(-90deg);
    transform-origin: top left;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Product media gallery manage UI (Foundry / CU / shared) */
.cosmos-pmg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cosmos-pmg__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.cosmos-pmg__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cosmos-pmg__thumb,
.cosmos-pmg__add {
  width: 112px;
  height: 84px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border);
  background: var(--card);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  cursor: pointer;
}
.cosmos-pmg__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.cosmos-pmg__thumb.is-hero {
  border-color: var(--acc);
}
.cosmos-pmg__badge {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accL);
  color: var(--acc);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  z-index: 1;
}
.cosmos-pmg__set-hero {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  border: none;
  background: var(--card);
  color: var(--acc);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.cosmos-pmg__del {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 999px;
  background: var(--navy, #0f172a);
  color: var(--card, #fff);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}
.cosmos-pmg__add {
  border-style: dashed;
  border-color: var(--acc);
  background: var(--accL);
  color: var(--acc2, var(--acc));
}
.cosmos-pmg__add-plus {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
.cosmos-pmg-host {
  margin-top: 4px;
}

/* -- KRA progress bars (task mix + Eye test / Gate Pass conversion) -- */
.cosmos-kra-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
  text-align: left;
}
.cosmos-kra-bar-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cosmos-kra-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  line-height: 1.35;
}
.cosmos-kra-bar-track {
  display: flex;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border, #EAECEF);
}
.cosmos-kra-bar-seg {
  height: 100%;
  min-width: 0;
  transition: width 0.25s ease;
}
.cosmos-kra-bar-seg--on-time { background: var(--green, #059669); }
.cosmos-kra-bar-seg--delayed { background: var(--gold, #D97706); }
.cosmos-kra-bar-seg--incomplete { background: var(--red, #DC2626); }
.cosmos-kra-bar-seg--fill {
  background: var(--acc, #1D6FD4);
  border-radius: 999px;
}
.cosmos-kra-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
  color: var(--text3);
  line-height: 1.35;
}
.cosmos-kra-bar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cosmos-kra-bar-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.cosmos-kra-bar-dot--on-time { background: var(--green, #059669); }
.cosmos-kra-bar-dot--delayed { background: var(--gold, #D97706); }
.cosmos-kra-bar-dot--incomplete { background: var(--red, #DC2626); }
.cosmos-kra-bar-dot--fill { background: var(--acc, #1D6FD4); }
