
/* SmartPanther responsive UI v10 — presentation only; no business logic */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { max-width: 100%; overflow-x: hidden; }
img, video, iframe, canvas, svg { max-width: 100%; }
button, .btn, input, select, textarea { touch-action: manipulation; }
button, .btn, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
.page, .main, .panel, .box, .dialog, .customerMain { min-width: 0; }
.tableWrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.tableWrap table { width: 100%; }
.toolbar, .pageHead, .panelHead, .dialogActions { min-width: 0; }
.toolbar > *, .pageHead > *, .panelHead > *, .dialogActions > * { min-width: 0; }
.toast { max-width: min(420px, calc(100vw - 24px)); }

/* Tablet: preserve a readable navigation rail and let dense data scroll locally. */
@media (min-width: 701px) and (max-width: 1100px) {
  input, select, textarea { min-height: 44px !important; font-size: 14px !important; }
  button, .btn { min-height: 44px; }
  .shell {
    grid-template-columns: clamp(164px, 21vw, 196px) minmax(0, 1fr) !important;
  }
  .sidebar { padding: 16px 10px !important; }
  .sidebar .brandPlate {
    padding: 12px 10px !important;
    min-width: 0;
  }
  .sidebar .brandWord {
    font-size: 13px !important;
    line-height: 1.05 !important;
    white-space: normal;
  }
  .sidebar .brandWord::before { content: none !important; }
  .sidebar .brandWord span { display: block !important; }
  .sidebar .sideNav button {
    display: flex !important;
    align-items: center;
    min-height: 44px;
    padding: 10px 11px !important;
    font-size: 11px !important;
    line-height: 1.2;
    white-space: normal;
  }
  .sidebar .sideNav button::first-letter { font-size: inherit !important; }
  .main { padding: 0 18px 42px !important; min-width: 0; }
  .topbar { padding-inline: 0 !important; }
  .pageHead {
    align-items: flex-start !important;
    flex-wrap: wrap;
    gap: 12px;
  }
  .pageHead > div:last-child,
  .spiCustomerHeadActions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ownerGrid, .assetGrid { grid-template-columns: minmax(0, 1fr) !important; }
  .machineGrid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .toolbar {
    height: auto !important;
    min-height: 58px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar input[type="search"],
  .toolbar input[type="text"] { min-width: 210px; flex: 1 1 240px; }
  .tableWrap table { min-width: 760px; }
  .dialog { width: min(760px, calc(100vw - 32px)) !important; }
  .previewGrid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* Phone: fixed thumb navigation, 44px touch targets, zoom-safe form fields. */
@media (max-width: 700px) {
  :root { --spi-mobile-nav-h: 68px; }

  body { padding-bottom: env(safe-area-inset-bottom); }

  input, select, textarea {
    min-height: 46px !important;
    font-size: 16px !important;
    line-height: 1.25;
  }
  textarea { min-height: 112px !important; resize: vertical; }
  button, .btn {
    min-height: 44px;
    padding-inline: 14px;
  }

  .authMain {
    min-height: 100dvh !important;
    align-items: flex-start !important;
    padding: max(18px, env(safe-area-inset-top)) 12px 24px !important;
  }
  .authCard {
    width: 100% !important;
    max-width: 560px !important;
    margin: 0 auto !important;
    border-radius: 16px !important;
  }
  .authCard .box,
  .authCard form { min-width: 0; }
  .authCard .btn,
  .authCard button[type="submit"] { width: 100%; }
  .authCard label { line-height: 1.3; }

  .shell {
    min-height: 100dvh;
    padding-bottom: calc(var(--spi-mobile-nav-h) + env(safe-area-inset-bottom));
  }
  .sidebar {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100% !important;
    height: calc(var(--spi-mobile-nav-h) + env(safe-area-inset-bottom)) !important;
    z-index: 80 !important;
    display: block !important;
    padding: 6px 8px max(6px, env(safe-area-inset-bottom)) !important;
    background: rgba(7, 10, 15, .98) !important;
    border: 0 !important;
    border-top: 1px solid rgba(255,255,255,.12) !important;
    box-shadow: 0 -10px 30px rgba(0,0,0,.28);
  }
  .sidebar .brandPlate { display: none !important; }
  .sidebar .sideNav {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch;
    gap: 6px !important;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar .sideNav::-webkit-scrollbar { display: none; }
  .sidebar .sideNav button {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 84px;
    min-height: 52px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 7px 10px !important;
    border-radius: 9px !important;
    font-size: 10px !important;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
  }
  .sidebar .sideNav button::first-letter { font-size: inherit !important; }
  .sidebar .sideNav button.active {
    box-shadow: inset 0 3px 0 var(--orange, #ff6a00);
  }

  .main { padding: 0 12px 28px !important; min-width: 0; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 45;
    height: auto !important;
    min-height: 58px;
    padding: 8px 0 !important;
    background: rgba(247,248,250,.94);
    backdrop-filter: blur(10px);
  }
  .topbar > * { min-width: 0; }

  .pageHead {
    padding: 20px 0 14px !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  .pageHead h1 { font-size: clamp(24px, 7.5vw, 31px) !important; }
  .pageHead p { max-width: 100%; }
  .pageHead > .btn { width: 100%; }
  .pageHead > div:last-child,
  .spiCustomerHeadActions {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
  }
  .spiCustomerHeadActions .btn,
  .pageHead > div:last-child .btn { width: 100%; }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .stat { min-width: 0; padding: 13px !important; }
  .stat strong { font-size: 23px !important; overflow-wrap: anywhere; }

  .panel, .box { border-radius: 12px !important; }
  .panelHead {
    height: auto !important;
    min-height: 52px;
    padding: 10px 12px !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  .panelHead .btn { flex: 1 1 auto; }

  .toolbar {
    height: auto !important;
    min-height: 0;
    padding: 10px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .toolbar input,
  .toolbar select,
  .toolbar .btn {
    width: 100% !important;
    min-width: 0 !important;
  }

  .tableWrap {
    width: 100%;
    border-radius: 0 0 12px 12px;
  }
  .tableWrap table { min-width: 720px; }
  th, td { padding: 11px 12px !important; }

  .grid2, .grid3, .ownerGrid, .assetGrid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .field { min-width: 0; }

  .modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .dialog {
    width: 100% !important;
    max-width: none !important;
    max-height: 92dvh !important;
    margin: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    overflow: hidden;
  }
  .dialogHead {
    height: auto !important;
    min-height: 56px;
    padding: 10px 14px !important;
  }
  .dialogBody {
    padding: 14px !important;
    padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .dialogActions {
    flex-wrap: wrap;
    gap: 8px !important;
  }
  .dialogActions .btn { flex: 1 1 140px; }

  .asset { align-items: flex-start !important; flex-wrap: wrap; }
  .asset > * { min-width: 0; }
  .assetActions { width: 100%; justify-content: flex-end; }

  .machineGrid { grid-template-columns: minmax(0, 1fr) !important; }
  .visual { height: clamp(190px, 58vw, 240px) !important; }
  .previewGrid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  .customerHeader {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 60px;
    height: auto !important;
    padding: 8px 12px !important;
    gap: 8px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
  }
  .customerHeader > * { min-width: 0; }
  .customerHeader .brandPlate { min-width: 0; width: auto; }
  .customerHeader .btn { padding-inline: 10px; }
  .customerMain { padding: 0 12px 30px !important; }
  .hero { min-height: 280px !important; padding: 24px 16px !important; }
  .hero h1 { font-size: clamp(30px, 9vw, 41px) !important; }
  .chips {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
  .cat { min-height: 42px; flex: 0 0 auto; scroll-snap-align: start; }

  .toast {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(var(--spi-mobile-nav-h) + 12px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
  }
}

@media (max-width: 430px) {
  .authMain { padding-inline: 8px !important; }
  .authCard { border-radius: 12px !important; }
  .authCard .box { padding: 18px 14px !important; }

  .stats { grid-template-columns: minmax(0, 1fr) !important; }
  .spiCustomerHeadActions,
  .pageHead > div:last-child {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .previewGrid { grid-template-columns: minmax(0, 1fr) !important; }
  .mobileBrand { width: min(205px, 75vw) !important; }
  .customerHeader .btn { font-size: 10px; padding-inline: 8px; }
}


/* Phone polish v4 — tuned for Galaxy S24 and iPhone 15 CSS viewports. */
@media (max-width: 700px) {
  .authCard {
    padding-top: 18px !important;
    padding-bottom: 20px !important;
  }
  .authCard .mobileBrand.spiMasterLogo {
    width: min(220px, 68vw) !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto 18px !important;
    padding: 6px 8px !important;
  }
  .authCard .mobileBrand.spiMasterLogo img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain;
  }
  .authCard h2 {
    font-size: clamp(22px, 6vw, 25px) !important;
    line-height: 1.12 !important;
    letter-spacing: -.02em;
    overflow-wrap: normal;
  }
  .authBottom {
    line-height: 1.5 !important;
    text-align: center;
  }

  .sidebar .sideNav {
    scroll-snap-type: x proximity;
    scroll-padding-inline: 0;
  }
  .sidebar .sideNav button {
    min-width: clamp(78px, 23.5vw, 94px);
    max-width: 96px;
    scroll-snap-align: start;
  }

  .topbar { gap: 8px; }
  .topbar > div:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }
  .topbar > .chipUser {
    max-width: 48vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 0 1 auto;
  }

  .customerHeader > div:last-child {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex: 0 0 auto;
  }
  .customerHeader .brandWord {
    font-size: 12px !important;
    line-height: 1.05 !important;
  }
  .customerHeader .brandWord span { font-size: 7px !important; }
}

@media (max-width: 430px) {
  .authMain {
    padding: max(10px, env(safe-area-inset-top)) 6px 20px !important;
  }
  .authCard {
    padding: 18px 10px 20px !important;
  }
  .authCard .box {
    padding: 16px 10px !important;
  }
  .authCard .mobileBrand.spiMasterLogo {
    width: min(205px, 62vw) !important;
    margin-bottom: 15px !important;
  }
  .authCard h2 {
    font-size: clamp(21px, 6vw, 23px) !important;
  }
  .pageHead { padding-top: 16px !important; }
  .pageHead h1 { font-size: clamp(23px, 7vw, 27px) !important; }
  .panelHead { padding-inline: 10px !important; }
  .sidebar { padding-inline: 6px !important; }
  .sidebar .sideNav { gap: 4px !important; }
  .sidebar .sideNav button {
    min-width: calc((100vw - 30px) / 4);
    max-width: 94px;
    padding-inline: 6px !important;
    font-size: 9.5px !important;
  }
  .customerHeader {
    padding-left: max(8px, env(safe-area-inset-left)) !important;
    padding-right: max(8px, env(safe-area-inset-right)) !important;
  }
}


/* Brand plate and mobile navigation fix v5. */
:root, html, body {
  color-scheme: only light !important;
}

#staffView .sidebar .brandPlate.spiMasterLogo,
#customerView .customerHeader .brandPlate.spiMasterLogo {
  background: #fff4df !important;
  border: 1px solid #f0c98f !important;
  border-radius: 14px !important;
  box-shadow: 0 10px 28px rgba(7, 31, 54, .16) !important;
  color-scheme: only light !important;
  overflow: hidden !important;
}

#staffView .sidebar .brandPlate.spiMasterLogo {
  margin-bottom: 12px !important;
  padding: 10px 12px !important;
}

#staffView .sidebar .brandPlate.spiMasterLogo img,
#customerView .customerHeader .brandPlate.spiMasterLogo img {
  filter: none !important;
  opacity: 1 !important;
}

#customerView .customerHeader .brandPlate.spiMasterLogo {
  width: min(230px, 48vw) !important;
  min-height: 50px !important;
  padding: 7px 10px !important;
}

#authView .authCard .brandPlate.spiMasterLogo,
.authCard .mobileBrand.spiMasterLogo {
  background: #fff4df !important;
  border: 1px solid #f0c98f !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 22px rgba(7, 31, 54, .10) !important;
  color-scheme: only light !important;
}

@media (max-width: 700px) {
  #staffView .sidebar .brandPlate.spiMasterLogo {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }

  #staffView .sidebar #sideNav {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
  }

  #staffView .sidebar #sideNav button {
    height: 52px !important;
  }
}


/* SmartPanther sidebar readability v6 */
#staffView .sidebar #sideNav button,
.sidebar .sideNav button {
  font-size: 13.5px !important;
  font-weight: 750 !important;
  line-height: 1.28 !important;
  letter-spacing: 0.01em;
}

#staffView .sidebar #sideNav button > [id$="Count"],
#staffView .sidebar #sideNav button > [id$="Badge"],
#staffView .sidebar #sideNav button > .count,
.sidebar .sideNav button > [id$="Count"],
.sidebar .sideNav button > [id$="Badge"],
.sidebar .sideNav button > .count {
  min-width: 24px !important;
  width: auto !important;
  height: 22px !important;
  padding: 0 7px !important;
  margin-left: auto !important;
  border: 2px solid #fff2df !important;
  border-radius: 999px !important;
  background: #ff941f !important;
  color: #071f4f !important;
  font-size: 11.5px !important;
  font-weight: 950 !important;
  line-height: 18px !important;
  letter-spacing: 0 !important;
  text-align: center !important;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
  box-shadow: 0 2px 7px rgba(7,31,79,.28) !important;
}

@media (min-width: 701px) and (max-width: 1100px) {
  #staffView .sidebar #sideNav button,
  .sidebar .sideNav button {
    font-size: 12.5px !important;
    line-height: 1.25 !important;
  }
}

@media (max-width: 700px) {
  #staffView .sidebar #sideNav button,
  .sidebar .sideNav button {
    position: relative !important;
    min-width: 96px !important;
    max-width: 108px !important;
    padding: 8px 12px !important;
    font-size: 11.25px !important;
    line-height: 1.2 !important;
  }

  #staffView .sidebar #sideNav button > [id$="Count"],
  #staffView .sidebar #sideNav button > [id$="Badge"],
  #staffView .sidebar #sideNav button > .count,
  .sidebar .sideNav button > [id$="Count"],
  .sidebar .sideNav button > [id$="Badge"],
  .sidebar .sideNav button > .count {
    position: absolute !important;
    top: 3px !important;
    right: 4px !important;
    min-width: 22px !important;
    height: 20px !important;
    padding: 0 6px !important;
    margin: 0 !important;
    font-size: 10.5px !important;
    line-height: 16px !important;
  }
}

@media (max-width: 430px) {
  #staffView .sidebar #sideNav button,
  .sidebar .sideNav button {
    min-width: 94px !important;
    max-width: 102px !important;
    padding-inline: 9px !important;
    font-size: 10.75px !important;
  }
}\n\n/* SmartPanther responsive hardening v7.
   Presentation only: no business rules, permissions, or data changes. */

html,
body,
#staffView,
#customerView,
.shell,
.main,
.page {
  max-width: 100%;
}

.page,
.dialog,
.dialogBody,
.tableWrap,
.spiOwnerPiDetail,
.spiSalesPiDetail,
.spiPoDetailGrid,
.spiPaymentRow,
.spiQuoteItem {
  min-width: 0;
}

.dialogBody,
td,
.spiOwnerPiDetail b,
.spiSalesPiDetail b,
.spiPoTrackCard b,
.spiPoHistoryRow p,
.spiQuoteMachine,
.spiPaymentRow,
.spiSalesOrderAlert {
  overflow-wrap: anywhere;
  word-break: normal;
}

.dialog {
  display: flex;
  flex-direction: column;
}

.dialogHead,
.dialogActions,
.modalActions {
  flex: 0 0 auto;
}

.dialogBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

input,
select,
textarea,
button {
  max-width: 100%;
}

.tableWrap {
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #ef7b16 #e8edf0;
}

.tableWrap::-webkit-scrollbar {
  height: 8px;
}

.tableWrap::-webkit-scrollbar-track {
  background: #e8edf0;
  border-radius: 999px;
}

.tableWrap::-webkit-scrollbar-thumb {
  background: #ef7b16;
  border-radius: 999px;
}

#spiCaptureInterestPanel {
  max-height: min(58dvh, 430px) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #ef7b16 #f3e4cf;
  touch-action: pan-y;
}

#spiCaptureInterestPanel::-webkit-scrollbar {
  width: 8px;
}

#spiCaptureInterestPanel::-webkit-scrollbar-thumb {
  background: #ef7b16;
  border-radius: 999px;
}

@media (min-width: 701px) and (max-width: 1100px) {
  .dialog {
    max-height: 92dvh !important;
  }

  .spiSalesPiPageHead,
  .spiOwnerPiHead,
  .sdHero,
  .od3Hero,
  .spiSalesOrderAlertsHead {
    flex-wrap: wrap;
  }

  .spiPoStats,
  .spiPoDetailGrid,
  .spiPoTracking,
  .spiPartnerGrid,
  .spiPiChecks,
  .spiUploadGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .spiPoProgress {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .spiPaymentRow {
    grid-template-columns: minmax(0, 1fr) minmax(150px, .8fr) !important;
  }

  .spiPaymentActions,
  .spiProofLine {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .page {
    width: 100%;
    overflow-x: hidden;
  }

  .dialog {
    max-height: min(94dvh, calc(100dvh - env(safe-area-inset-top))) !important;
  }

  .dialogHead {
    position: relative;
    z-index: 3;
  }

  .dialogActions,
  .modalActions,
  .spiOwnerPiModalActions,
  .spiPdfActions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    width: 100%;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom)) !important;
    background: #fff;
    border-top: 1px solid #e2e7ea;
    box-shadow: 0 -8px 18px rgba(7, 31, 54, .07);
  }

  .dialogActions .btn,
  .modalActions .btn,
  .spiOwnerPiModalActions .btn,
  .spiPdfActions .btn {
    flex: 1 1 140px;
    min-width: 0;
  }

  .tableWrap table {
    min-width: 640px !important;
  }

  .tableWrap th,
  .tableWrap td {
    white-space: normal;
  }

  .tableWrap th:last-child,
  .tableWrap td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -8px 0 14px rgba(7, 31, 54, .07);
  }

  .tableWrap thead th:last-child {
    z-index: 3;
    background: #f7f9fa;
  }

  /* Empty-state rows commonly use one cell with colspan. They must remain
     normal-flow content instead of becoming a sticky action column. */
  .tableWrap tr > td:only-child,
  .tableWrap tr > td[colspan] {
    position: sticky !important;
    left: 0 !important;
    right: auto !important;
    width: calc(100vw - 26px) !important;
    max-width: calc(100vw - 26px) !important;
    white-space: normal !important;
    text-align: left !important;
    overflow-wrap: anywhere;
    box-shadow: none !important;
  }

  .sdHero,
  .od3Hero,
  .spiSalesPiPageHead,
  .spiOwnerPiHead,
  .spiSalesPiNotice,
  .spiOwnerPiNotice,
  .spiSalesOrderAlertsHead,
  .spiSalesOrderAlert,
  .spiProofLine,
  .spiBankState {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  .sdHero > .btn,
  .od3Hero > .btn,
  .spiSalesPiPageHead > .btn,
  .spiOwnerPiHead > .btn,
  .spiSalesPiNotice .btn,
  .spiOwnerPiNotice .btn,
  .spiSalesOrderAlertsHead .btn,
  .spiSalesOrderAlert .btn,
  .spiProofLine .btn {
    width: 100%;
  }

  .spiOwnerPiTabs {
    display: flex !important;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .spiOwnerPiTab {
    flex: 0 0 auto;
    min-height: 44px;
  }

  .spiOwnerPiActions,
  .spiSalesPiActions,
  .spiPaymentActions,
  .spiReviewActions,
  .spiPoActions,
  .crmLeadQuickActions {
    display: flex !important;
    flex-wrap: wrap !important;
    white-space: normal !important;
    gap: 8px !important;
  }

  .spiOwnerPiActions .btn,
  .spiSalesPiActions .btn,
  .spiPaymentActions .btn,
  .spiReviewActions .btn,
  .spiPoActions .btn,
  .crmLeadQuickActions .btn {
    flex: 1 1 132px;
    min-width: 0;
  }

  .spiPoStats,
  .spiPoDetailGrid,
  .spiPoTracking,
  .spiPartnerGrid,
  .spiPiChecks,
  .spiUploadGrid,
  .spiPaymentRow,
  .spiPoItem,
  .spiQuoteAddPanel,
  .spiQuoteSummary,
  .spiPaymentGrid,
  .spiPdfFixedGrid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .spiPoItemName,
  .spiPaymentUploadForm,
  .spiProofLine {
    grid-column: auto !important;
  }

  .spiPoLineTotal,
  .spiPaymentAmount {
    align-self: auto !important;
    text-align: left !important;
    padding-bottom: 0 !important;
  }

  .spiQuotePiLink,
  .spiRateCard {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  .spiQuotePiLink .btn {
    width: 100%;
  }

  .spiPoHistoryRow,
  .crmLeadTimelineItem,
  .spiOwnerPiDetail,
  .spiSalesPiDetail {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .od3Filters,
  .crmLeadToolbar {
    width: 100%;
  }

  .od3Filters > *,
  .crmLeadToolbar > * {
    min-width: 0 !important;
    width: 100% !important;
  }

  .spiWorkMode {
    width: 100%;
  }

  .spiWorkMode select {
    min-width: 0;
    width: 100%;
  }

  details > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  input,
  select,
  textarea,
  button,
  .btn {
    scroll-margin-bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .spiOwnerPricingGrid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .spiOwnerPricingGrid .field:last-child {
    grid-column: auto !important;
  }

  .spiPoProgress {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .spiQuoteItem {
    grid-template-columns: 18px minmax(0, 1fr) !important;
  }

  .spiQuoteQtyWrap,
  .spiQuotePrice {
    grid-column: 2 !important;
  }
}

@media (max-height: 700px) {
  .dialog {
    max-height: 96dvh !important;
  }

  .dialogBody {
    padding-top: 10px !important;
  }
}



/* Preserve permission visibility after responsive display rules. */
#staffView .sidebar #sideNav button.hidden,
.sidebar .sideNav button.hidden {
  display: none !important;
}

/* Galaxy Z Fold8 responsive tuning v10.
   Presentation only: no data, permissions, or business-rule changes. */
@media (min-width: 701px) and (max-width: 1100px) {
  /* The unfolded 4:3 display is wide but short: keep every navigation item reachable. */
  #staffView .sidebar {
    max-height: 100dvh !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 148, 31, .75) transparent;
    padding-bottom: max(18px, env(safe-area-inset-bottom)) !important;
  }

  #installationTrainingPage {
    width: 100%;
    min-width: 0;
  }

  #installationTrainingPage .spiFlowHero {
    display: flex !important;
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    gap: 12px 16px !important;
  }

  #installationTrainingPage .spiFlowHero > div {
    flex: 1 1 330px;
    min-width: 0;
  }

  #installationTrainingPage .spiFlowHero h1 {
    max-width: 100%;
    font-size: clamp(28px, 4.2vw, 38px) !important;
    line-height: 1.08 !important;
    overflow-wrap: anywhere;
  }

  #installationTrainingPage .spiFlowStats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  #installationTrainingPage .spiFlowTabs {
    display: flex !important;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  #installationTrainingPage .spiFlowTab {
    min-height: 44px;
    flex: 0 0 auto;
  }

  #installationTrainingPage .spiFlowTableWrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #ef7b16 #e8edf0;
  }

  #installationTrainingPage .spiFlowTable {
    min-width: 720px;
  }
}

@media (max-width: 700px) {
  #installationTrainingPage {
    width: 100%;
    min-width: 0;
  }

  #installationTrainingPage .spiFlowHero {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  #installationTrainingPage .spiFlowHero > div {
    width: 100%;
    min-width: 0;
  }

  #installationTrainingPage .spiFlowHero h1 {
    max-width: 100%;
    font-size: clamp(26px, 8vw, 32px) !important;
    line-height: 1.08 !important;
    overflow-wrap: anywhere;
  }

  #installationTrainingPage .spiFlowHero > .btn,
  #installationTrainingPage .spiFlowHero > button {
    width: 100%;
  }

  #installationTrainingPage .spiFlowStats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  #installationTrainingPage .spiFlowStat {
    min-width: 0;
    padding: 12px !important;
  }

  #installationTrainingPage .spiFlowTabs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100%;
  }

  #installationTrainingPage .spiFlowTab {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  #installationTrainingPage .spiFlowTableWrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #ef7b16 #e8edf0;
  }

  #installationTrainingPage .spiFlowTable {
    min-width: 660px;
  }

  #installationTrainingPage .spiFlowTable th:last-child,
  #installationTrainingPage .spiFlowTable td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -8px 0 14px rgba(7, 31, 54, .07);
  }

  #installationTrainingPage .spiFlowTable thead th:last-child {
    z-index: 3;
    background: #f7f9fa;
  }
}

@media (max-width: 480px) {
  /* Compact two-row header for the Fold8 cover display. */
  #staffView .topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto !important;
    align-items: center !important;
    gap: 6px 8px !important;
    min-height: 0 !important;
    padding-block: 8px !important;
  }

  #staffView .topbar > div:first-child {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  #staffView .topbar > .chipUser {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    max-width: 47vw;
  }

  #staffView .topbar > .spiWorkMode {
    grid-column: 1;
    grid-row: 2;
    order: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    overflow: hidden;
  }

  #staffView .topbar > .spiMobileLogout {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    width: auto !important;
    min-width: 104px;
    margin: 0 !important;
  }

  #staffView .topbar .spiWorkMode select {
    width: auto !important;
    min-width: 92px !important;
    max-width: 118px;
  }

  #installationTrainingPage .spiFlowStats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 360px) {
  #staffView .topbar {
    grid-template-columns: minmax(0, 1fr) 96px !important;
  }

  #staffView .topbar > .spiMobileLogout {
    min-width: 96px;
    padding-inline: 8px !important;
  }

  #staffView .topbar .spiWorkMode > span:last-child {
    display: none !important;
  }

  #installationTrainingPage .spiFlowStats {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}


/* Fold/tablet sidebar label alignment v11.
   Keep a stable icon gutter and a separate badge column when long labels wrap. */
@media (min-width: 701px) and (max-width: 1100px) {
  #staffView .sidebar #sideNav button {
    display: block !important;
    position: relative !important;
    min-height: 44px !important;
    padding: 10px 40px 10px 32px !important;
    text-align: left !important;
    text-indent: -18px !important;
    white-space: normal !important;
    line-height: 1.25 !important;
    overflow-wrap: normal !important;
  }

  #staffView .sidebar #sideNav button > .spiPaymentNavLabel {
    display: block !important;
    min-width: 0 !important;
    text-align: left !important;
    text-indent: -18px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
  }

  #staffView .sidebar #sideNav button > [id$="Count"],
  #staffView .sidebar #sideNav button > [id$="Badge"],
  #staffView .sidebar #sideNav button > .count {
    position: absolute !important;
    top: 50% !important;
    right: 8px !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    text-indent: 0 !important;
  }
}

/* Fold cover-display bottom navigation containment v12.
   Long labels stay inside their own scrollable navigation item. */
@media (max-width: 700px) {
  #staffView .sidebar #sideNav button {
    flex: 0 0 102px !important;
    width: 102px !important;
    min-width: 102px !important;
    max-width: 102px !important;
    overflow: hidden !important;
    white-space: normal !important;
    scroll-snap-align: start;
  }

  #staffView .sidebar #sideNav button > .spiPaymentNavLabel {
    display: block !important;
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    text-align: center !important;
    font-size: inherit !important;
    line-height: inherit !important;
  }
}
