/* Javenzi contractor workspace — phone-first layout corrections.
   Kept separate from the legacy stylesheet so mobile ownership stays obvious. */

/* Desktop & Laptop Default Guards: hide mobile-only helper components on screens > 768px */
.boq-mobile-cell-label {
  display: none;
}
.boq-breakdown-toggle-btn {
  display: none;
}
.boq-stepper-btn {
  display: none;
}
.hide-on-mobile {
  display: inherit;
}
.show-on-mobile {
  display: none !important;
}

@media (max-width: 768px) {
  .app-shell,
  .workspace,
  .main,
  .panel,
  .page-header,
  .stats-strip,
  #dashKPIGrid {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  *, *::before, *::after { box-sizing: border-box; }
  body { overflow-x: hidden !important; }
  .hide-on-mobile { display: none !important; }
  .show-on-mobile { display: inline-flex !important; }

  header#topbar {
    height: 58px !important;
    padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)) !important;
    gap: 6px !important;
  }
  .topbar-left,
  .topbar-right { gap: 6px !important; min-width: 0 !important; }
  .topbar-page-title,
  .topbar-datetime { display: none !important; }
  .topbar-menu-btn,
  .topbar-btn,
  .topbar-btn-icon {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    justify-content: center !important;
  }
  #todoBtn { font-size: 0 !important; position: relative !important; }
  #todoBtn .j360-icon { width: 21px !important; height: 21px !important; }
  #todoBtn .todo-btn-badge {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    font-size: 9px !important;
  }
  .topbar-sync-badge { min-width: 0 !important; padding: 8px 10px !important; }

  .main {
    width: 100% !important;
    padding: 16px 14px calc(88px + env(safe-area-inset-bottom)) !important;
    overflow-x: clip !important;
  }
  .page-header {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 14px !important;
  }
  .page-title { overflow-wrap: anywhere !important; }
  .page-subtitle { max-width: 100% !important; }
  .page-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .page-actions > button,
  .page-actions > .btn { width: 100% !important; min-width: 0 !important; }

  /* A phone needs readable cards, not a compressed desktop KPI row.
     IMPORTANT: Only force-grid on strips that are *not* hidden via inline
     style — several panels hide secondary strips with style="display:none;"
     and the !important here must not override that intentional hide.
     We therefore restrict the broad .panel .stats-strip rule to elements
     that are not carrying an inline display:none declaration. */
  .panel .stats-strip:not([style*="display:none"]):not([style*="display: none"]):not([hidden]),
  #projectKPIs,
  #hrKPIStrip,
  #cfKPIStrip,
  #accGlobalKPIs {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  /* Guarantee that JS-hidden strips stay hidden on mobile. */
  .panel .stats-strip[style*="display:none"],
  .panel .stats-strip[style*="display: none"],
  .panel .stats-strip[hidden] {
    display: none !important;
  }
  .panel .stats-strip > .stat-card,
  #cfKPIStrip > .stat-card {
    min-width: 0 !important;
    width: auto !important;
    padding: 14px !important;
  }
  .panel .stat-label,
  .panel .stat-card-label { overflow-wrap: normal !important; word-break: normal !important; }
  .panel .stat-value,
  .panel .stat-card-value {
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    font-size: clamp(15px, 4.25vw, 21px) !important;
    line-height: 1.2 !important;
  }

  /* Tabs remain one natural row and can be swiped, matching native apps. */
  .panel .subtab-bar,
  .panel .mode-tabs,
  .panel .resource-tabs,
  #settingsModal .subtab-bar,
  #userMgmtModal .subtab-bar {
    max-width: 100% !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    overscroll-behavior-x: contain !important;
  }
  .panel .subtab-bar::-webkit-scrollbar,
  .panel .mode-tabs::-webkit-scrollbar,
  .panel .resource-tabs::-webkit-scrollbar { display: none !important; }
  .panel .subtab-bar > *,
  .panel .mode-tabs > *,
  .panel .resource-tabs > * { flex: 0 0 auto !important; }

  /* Shared register layout: identity first, actions below it at tap size. */
  .register-card,
  .card,
  .config-block { min-width: 0 !important; max-width: 100% !important; }
  .register-card-header,
  .card-header {
    align-items: flex-start !important;
    flex-direction: column !important;
    gap: 14px !important;
    padding: 16px !important;
  }
  .register-card-identity { width: 100% !important; min-width: 0 !important; align-items: flex-start !important; }
  .register-card-identity > div:last-child { min-width: 0 !important; }
  .register-card-title,
  .register-card-sub { max-width: 100% !important; overflow-wrap: normal !important; word-break: normal !important; }
  .register-card-actions,
  .card-header-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-left: 0 !important;
  }
  .register-card-actions > *,
  .card-header-actions > * {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    justify-content: center !important;
    white-space: normal !important;
  }
  .register-card-actions > :only-child,
  .card-header-actions > :only-child { grid-column: 1 / -1 !important; }
  .register-card-toolbar,
  .table-toolbar {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 10px !important;
  }
  .register-card-toolbar > *,
  .table-toolbar > * { width: 100% !important; max-width: none !important; min-width: 0 !important; }
  .table-wrap {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important;
  }

  /* Statutory documents: each field becomes a readable row on a phone. */
  #statutoryDocsContainer > div > div:first-child {
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
  }
  #statutoryDocsContainer > div > div:last-child {
    align-items: flex-start !important;
    flex-direction: column !important;
  }
  #statutoryDocsContainer [data-tooltip] { max-width: 100% !important; }
  #statutoryDocsContainer span[data-tooltip] {
    width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  #dashKPIGrid { grid-template-columns: 1fr !important; gap: 12px !important; }
  #dashKPIGrid .dash-kpi { min-width: 0 !important; padding: 18px !important; }
  #dashKPIGrid .dash-kpi-value {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    font-size: clamp(20px, 7vw, 28px) !important;
    line-height: 1.15 !important;
  }

  #projectKPIs { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #projectKPIs .stat-card { min-width: 0 !important; }
  #projectKPIs .stat-value {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    font-size: clamp(17px, 5vw, 23px) !important;
    line-height: 1.2 !important;
  }

  #settingsModal { padding: 0 !important; align-items: stretch !important; }
  #settingsModal .settings-modal-box {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border: 0 !important;
    border-radius: 0 !important;
  }
  #settingsModal .settings-modal-header {
    padding: calc(12px + env(safe-area-inset-top)) 14px 12px !important;
  }
  #settingsModal .settings-modal-title-wrap { gap: 10px !important; min-width: 0 !important; }
  #settingsModal .settings-modal-title { font-size: 15px !important; }
  #settingsModal .settings-modal-sub {
    max-width: calc(100vw - 116px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #settingsModal .settings-modal-body { flex-direction: column !important; }
  #settingsModal .settings-nav {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 58px !important;
    padding: 8px 10px !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-right: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    scrollbar-width: none !important;
  }
  #settingsModal .settings-nav::-webkit-scrollbar { display: none !important; }
  #settingsModal .settings-nav-item {
    width: auto !important;
    min-height: 40px !important;
    flex: 0 0 auto !important;
    padding: 9px 12px !important;
  }
  #settingsModal .settings-nav-item.active {
    border-left: 0 !important;
    border-bottom: 3px solid var(--accent) !important;
  }
  #settingsModal .settings-content-pane {
    width: 100% !important;
    padding: 18px 14px calc(26px + env(safe-area-inset-bottom)) !important;
  }
  #settingsModal .settings-field-row { grid-template-columns: 1fr !important; gap: 10px !important; }
  #settingsModal .settings-content-pane .config-block { padding: 15px !important; }
  #settingsModal .settings-modal-footer {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom)) !important;
  }
  #settingsModal .settings-modal-footer-hint {
    font-size: 11px !important;
  }
  #settingsModal .settings-modal-footer-actions {
    width: 100% !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
  }
  #settingsModal .settings-modal-footer-actions .btn {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  /* User management is a task screen on phones, not a floating desktop card. */
  #userMgmtModal { padding: 0 !important; align-items: stretch !important; }
  #userMgmtModal .j360-modal-box {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border: 0 !important;
    border-radius: 0 !important;
  }
  #userMgmtModal .j360-modal-body { padding: 14px !important; }
  #userMgmtModal .j360-modal-footer {
    display: grid !important;
    grid-template-columns: 1fr 1.35fr !important;
    gap: 8px !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }
  #userMgmtModal .j360-modal-footer > * { width: 100% !important; min-width: 0 !important; }
  .um-user-card { align-items: flex-start !important; flex-wrap: wrap !important; padding: 14px !important; }
  .um-user-main { flex: 1 1 calc(100% - 56px) !important; min-width: 0 !important; }
  .um-user-name { flex-wrap: wrap !important; white-space: normal !important; }
  .um-user-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    margin: 10px 0 0 !important;
  }
  .um-user-actions > * { width: 100% !important; min-width: 0 !important; justify-content: center !important; }

  /* Complex editors keep their desktop capability, but expose their controls
     as swipeable phone ribbons and dedicate the viewport to one workspace. */
  #wpOverlay .wp-mobile-header,
  #twpOverlay .wp-mobile-header,
  #tboqOverlay .tboq-mobile-header {
    padding: calc(6px + env(safe-area-inset-top)) 10px 6px !important;
    gap: 6px !important;
    min-height: 44px !important;
  }
  #wpOverlay .wp-mobile-header::-webkit-scrollbar,
  #twpOverlay .wp-mobile-header::-webkit-scrollbar,
  #tboqOverlay .tboq-mobile-header::-webkit-scrollbar { display: none !important; }
  #wpOverlay .wp-mobile-identity,
  #twpOverlay .wp-mobile-identity,
  #wpOverlay .j360-modal-icon,
  #twpOverlay .j360-modal-icon,
  #wpOverlay .wp-identity-icon,
  #twpOverlay .wp-identity-icon,
  #tboqOverlay .tboq-mobile-identity { display: none !important; }
  #wpOverlay .wp-mobile-header-actions,
  #twpOverlay .wp-mobile-header-actions,
  #tboqOverlay .tboq-mobile-header-actions {
    width: 100% !important;
    margin: 0 !important;
    justify-content: flex-end !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
  }
  #wpOverlay .wp-mobile-header-actions::-webkit-scrollbar,
  #twpOverlay .wp-mobile-header-actions::-webkit-scrollbar,
  #tboqOverlay .tboq-mobile-header-actions::-webkit-scrollbar { display: none !important; }
  #wpOverlay .wp-mobile-ribbon,
  #twpOverlay .wp-mobile-ribbon,
  #tboqOverlay .tboq-mobile-ribbon {
    min-height: 44px !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 6px 10px !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    scrollbar-width: none !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
  }
  #wpOverlay .wp-mobile-ribbon::-webkit-scrollbar,
  #twpOverlay .wp-mobile-ribbon::-webkit-scrollbar,
  #tboqOverlay .tboq-mobile-ribbon::-webkit-scrollbar { display: none !important; }
  #wpOverlay .wp-mobile-ribbon > div,
  #twpOverlay .wp-mobile-ribbon > div,
  #tboqOverlay .tboq-mobile-ribbon > div {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    margin-left: 0 !important;
  }
  #wpOverlay .wp-mobile-ribbon > div > *,
  #twpOverlay .wp-mobile-ribbon > div > *,
  #wpOverlay .wp-mobile-ribbon > *,
  #twpOverlay .wp-mobile-ribbon > *,
  #tboqOverlay .tboq-mobile-ribbon > * { flex: 0 0 auto !important; white-space: nowrap !important; }
  #wpOverlay .wp-mobile-ribbon-secondary,
  #twpOverlay .wp-mobile-ribbon-secondary { display: none !important; }
  #wpOverlay #wpGanttScroll {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  #wpOverlay #wpGanttTable {
    min-width: 960px !important;
    width: max-content !important;
  }
  #wpOverlay #wpGanttScroll th[style*="position:sticky;left:0"],
  #wpOverlay #wpGanttScroll th[style*="position: sticky; left: 0"],
  #wpOverlay #wpGanttScroll td.wp-task-left-td,
  #wpOverlay #wpGanttScroll td[style*="position:sticky;left:0"],
  #wpOverlay #wpGanttScroll td[style*="position: sticky; left: 0"] {
    position: static !important;
    box-shadow: none !important;
  }
  #wpOverlay #wpGanttScroll .wp-main-border-resizer {
    display: none !important;
  }
  #tboqOverlay .tboq-mobile-workspace {
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  #tboqOverlay #tboqScrollWrap {
    width: 100vw !important;
    min-height: 48dvh !important;
    flex: 0 0 auto !important;
    overflow: auto !important;
  }
  #tboqOverlay .tboq-mobile-advisor {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    flex: 0 0 auto !important;
  }

  /* Overhead arrears cards keep the warning and actions in separate rows. */
  .oh-arrears-row { align-items: flex-start !important; flex-direction: column !important; gap: 14px !important; }
  .oh-arrears-main { width: 100% !important; min-width: 0 !important; }
  .oh-arrears-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .oh-arrears-actions > * { width: 100% !important; min-width: 0 !important; justify-content: center !important; }

  /* Document controls stay inside the safe area while the document itself is
     reflowed by doc-viewer.js inside its isolated iframe. */
  #j360DocViewerSaveMenu {
    top: calc(8px + env(safe-area-inset-top)) !important;
    right: max(8px, env(safe-area-inset-right)) !important;
  }
  #j360DocViewerVaultState { display: none !important; }
  #j360DocViewerFrame { width: 100vw !important; height: 100dvh !important; }

  /* The PDF preview becomes a true phone task screen. Its title stays above a
     four-action grid, so Close can never be pushed beyond the viewport. */
  #j360PdfPreviewModal {
    padding: 0 !important;
    align-items: stretch !important;
  }
  #j360PdfPreviewModal .j360-pdf-preview-shell {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border: 0 !important;
    border-radius: 0 !important;
  }
  #j360PdfPreviewModal .j360-pdf-preview-header {
    align-items: stretch !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 10px max(10px, env(safe-area-inset-left)) !important;
  }
  #j360PdfPreviewModal .j360-pdf-preview-heading { width: 100% !important; }
  #j360PdfPreviewModal .j360-pdf-preview-actions {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }
  #j360PdfPreviewModal .j360-pdf-preview-actions .btn {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
    padding: 7px 4px !important;
    gap: 4px !important;
    font-size: 10px !important;
    justify-content: center !important;
  }
  #j360PdfPreviewPages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: auto !important;
    padding: 12px max(10px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)) !important;
    background: var(--surface3) !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  #j360PdfPreviewPages canvas {
    display: block !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto 12px !important;
    background: #fff !important;
    box-shadow: var(--shadow-card) !important;
  }

  /* NeST Procurement Document Checklist Rows on Mobile */
  .nest-checklist-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 10px !important;
  }

  .nest-row-header {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    grid-template-rows: auto auto !important;
    column-gap: 8px !important;
    row-gap: 4px !important;
    align-items: start !important;
    width: 100% !important;
  }

  .nest-row-icon {
    grid-column: 1 !important;
    grid-row: 1 !important;
    font-size: 22px !important;
    margin-top: 1px !important;
  }

  .nest-row-info {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0 !important;
  }

  .nest-row-title-line {
    font-size: 12.5px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    word-break: normal !important;
  }

  .nest-row-chip-box {
    grid-column: 3 !important;
    grid-row: 1 !important;
    margin-left: 0 !important;
    justify-self: end !important;
  }

  .nest-row-desc {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    font-size: 11px !important;
    color: var(--text3) !important;
    line-height: 1.4 !important;
    margin-top: 4px !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  .nest-row-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding-top: 8px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
    flex-wrap: wrap !important;
  }

  .nest-row-actions .nest-checklist-btn,
  .nest-row-actions > button {
    flex: 1 1 0px !important;
    min-width: 75px !important;
    min-height: 38px !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    justify-content: center !important;
    text-align: center !important;
  }
}

@media (max-width: 520px) {
  #projectKPIs .stat-card { padding: 14px !important; }
  #projectKPIs .stat-value { overflow-wrap: normal !important; }
  .topbar-sync-badge .sync-badge-label { display: none !important; }
  .topbar-sync-badge { width: 40px !important; height: 40px !important; justify-content: center !important; }
}

/* ============================================================
   PHASE 1 — MOBILE UX UPGRADES
   All rules below are either outside @media (for structural
   base styles that are inert on desktop) or inside a phone
   media query. Desktop/laptop layout is NOT touched.
   ============================================================ */

/* ──────────────────────────────────────────────────────────────
   1.  MORE-MENU BOTTOM SHEET  (base structure, always present;
       visibility controlled by .open — only shown on phones
       because the bottom-nav that triggers it is display:none
       on desktop, so the sheet is never opened on desktop.)
   ────────────────────────────────────────────────────────────── */

/* Frosted backdrop */
.more-menu-backdrop {
  display: none;           /* hidden until .open */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 340;
  /* Sits below the sheet (z:350) but above every panel */
}
.more-menu-backdrop.open { display: block; }

/* Bottom sheet panel */
.more-menu-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 350;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border2, var(--border));
  padding: 0 0 0;
  display: flex;
  flex-direction: column;
  max-height: 80dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* Slide from bottom — starts off-screen */
  transform: translateY(100%);
  transition: transform 0.27s cubic-bezier(0.32, 0.72, 0, 1);
  /* Shadow gives it depth over the backdrop */
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.35);
}
.more-menu-sheet.open {
  transform: translateY(0);
}

/* Grab handle */
.more-menu-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border2, var(--border));
  margin: 12px auto 8px;
  flex-shrink: 0;
}

/* Sheet title */
.more-menu-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 18px 12px;
  flex-shrink: 0;
}

/* Module grid — 3 columns of icon+label tiles */
.more-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 12px 12px;
}

/* Each tile */
.more-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 76px;
  padding: 12px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  line-height: 1.25;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  /* Tap highlight */
  -webkit-tap-highlight-color: transparent;
}
.more-menu-item:active {
  background: var(--surface3);
}
.more-menu-item.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(252, 225, 1, 0.06);
}
.more-menu-item[hidden] { display: none; }

.more-menu-icon {
  width: 24px !important;
  height: 24px !important;
  flex-shrink: 0;
}

/* Safe-area padding at bottom of sheet */
.more-menu-safe-area {
  flex-shrink: 0;
  height: env(safe-area-inset-bottom, 0px);
  min-height: 8px;
}

/* ──────────────────────────────────────────────────────────────
   2.  UNIVERSAL j360-MODAL BOTTOM SHEET  (phones only)
       Every modern modal that uses .j360-modal-box slides up
       from the bottom as a full-height task sheet.
       Exceptions that already have their own full-screen rules
       (#settingsModal, #userMgmtModal, #j360PdfPreviewModal)
       keep their existing styles above and are excluded here.
   ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Overlay aligns to bottom so the sheet slides up flush */
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) {
    align-items: flex-end !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* The sheet itself */
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-box,
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-container {
    width: 100vw !important;
    max-width: 100vw !important;
    /* 94dvh leaves a small visible strip above so the user knows it's a sheet */
    height: 94dvh !important;
    max-height: 94dvh !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    /* Replace scale+translateY desktop animation with slide-up */
    animation: j360ModalSheetIn 0.27s cubic-bezier(0.32, 0.72, 0, 1) !important;
  }

  @keyframes j360ModalSheetIn {
    from { transform: translateY(100%); opacity: 1; }
    to   { transform: translateY(0);   opacity: 1; }
  }

  /* Sticky header — stays at top while body scrolls */
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1 !important;
    border-radius: 0 !important;
    /* Compact it slightly for phone real-estate */
    padding: 10px 14px !important;
  }

  /* Scrollable body */
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 14px !important;
    min-height: 0 !important;
  }

  /* Sticky footer with safe-area padding */
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-footer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 1 !important;
    border-radius: 0 !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Footer buttons take full row, min 44px tall */
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-footer > .btn,
  .j360-modal-overlay:not(#settingsModal):not(#j360PdfPreviewModal) .j360-modal-footer > button {
    flex: 1 1 auto !important;
    min-height: 44px !important;
    justify-content: center !important;
  }

  /* Collapse 2-column form grids to single column inside modal body */
  .j360-modal-body .grid-2,
  .j360-modal-body [style*="grid-template-columns:1fr 1fr"],
  .j360-modal-body [style*="grid-template-columns: 1fr 1fr"],
  .j360-modal-body [style*="repeat(2,"],
  .j360-modal-body [style*="repeat(2, "] {
    grid-template-columns: 1fr !important;
  }
  /* Step bars (wizard steps) — scroll horizontally on phones */
  .modal-step-bar,
  #boqStepBar {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .modal-step-bar::-webkit-scrollbar,
  #boqStepBar::-webkit-scrollbar { display: none !important; }

  /* ──────────────────────────────────────────────────────────────
     3.  44px MINIMUM TOUCH TARGETS & 16px INPUT FONT (no iOS zoom)
         Desktop: .table-action-btn and .btn-icon-only stay 28×28px.
         Phone: they grow to 44×44px minimum — tappable on a
         construction site with gloves or a dusty screen.
     ────────────────────────────────────────────────────────────── */

  /* Table action buttons: icon-only edit/delete/view buttons */
  .btn.btn-icon-only,
  .btn-icon-only,
  .table-action-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 44px !important;
    max-height: 44px !important;
  }

  /* Regular action buttons */
  .btn:not(.btn-icon-only):not(.table-action-btn) {
    min-height: 44px !important;
  }

  /* All text/number inputs must be at least 16px so iOS does NOT
     zoom the viewport when the user taps into the field. */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  input[type="tel"],
  input[type="date"],
  input[type="search"],
  input[type="url"],
  select,
  textarea {
    font-size: 16px !important;
    /* Also ensure tappable height */
    min-height: 44px !important;
  }

  /* Checkboxes and radio buttons need a large hit-area wrapper.
     We enlarge the element itself; a ::before pseudo target would
     need JS to coordinate — this is simpler and safe. */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px !important;
    min-height: 20px !important;
    width: 20px !important;
    height: 20px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     4.  UNIVERSAL GRID COLLAPSE (.grid-3, .grid-4)
         Stack 3-column and 4-column forms into 1-column on mobile.
     ────────────────────────────────────────────────────────────── */
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     5.  PHASE 2: CONTRACT BOQ HORIZONTAL SPREADSHEET TABLE
         Preserves 11-column spreadsheet layout with smooth touch
         horizontal scroll (Tender BOQ Pricing Engine standard).
     ────────────────────────────────────────────────────────────── */
  .boq-project-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 540px !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    background: var(--surface) !important;
    margin-top: 8px !important;
  }
  .boq-project-table {
    display: table !important;
    min-width: 1120px !important;
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 11px !important;
  }
  .boq-project-table .boq-mobile-cell-label {
    display: none !important;
  }
  .boq-project-table colgroup {
    display: table-column-group !important;
  }
  .boq-project-table thead {
    display: table-header-group !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background: var(--surface2) !important;
  }
  .boq-project-table thead th {
    display: table-cell !important;
    padding: 8px 6px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: var(--text2) !important;
    border-bottom: 2px solid var(--border) !important;
    white-space: nowrap !important;
  }
  .boq-project-table tbody {
    display: table-row-group !important;
  }
  .boq-project-table tfoot {
    display: table-footer-group !important;
    position: sticky !important;
    bottom: 0 !important;
    background: var(--surface3) !important;
  }
  .boq-project-table tfoot tr {
    display: table-row !important;
    background: var(--surface3) !important;
  }
  .boq-project-table tfoot tr > td {
    display: table-cell !important;
    padding: 8px 6px !important;
    font-size: 11px !important;
    border-top: 2px solid var(--border) !important;
  }
  .boq-project-table tr.boq-section-header {
    display: table-row !important;
    background: var(--surface2) !important;
  }
  .boq-project-table tr.boq-section-header td {
    display: table-cell !important;
    padding: 8px 10px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    border-top: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .boq-project-table tr.boq-item-row,
  .boq-project-table tr.boq-omitted-row,
  .boq-project-table tr.boq-superseded-row {
    display: table-row !important;
    background: var(--surface) !important;
  }
  .boq-project-table tr.boq-item-row > td,
  .boq-project-table tr.boq-omitted-row > td,
  .boq-project-table tr.boq-superseded-row > td {
    display: table-cell !important;
    padding: 6px 6px !important;
    font-size: 11px !important;
    vertical-align: middle !important;
    border-top: 1px solid var(--border) !important;
  }
  /* Item Description styling inside horizontal table */
  .boq-project-table td.boq-col-desc {
    font-size: 11px !important;
    line-height: 1.35 !important;
    color: var(--text) !important;
    min-width: 220px !important;
  }
  .boq-project-table td.boq-col-desc .boq-desc-text {
    font-weight: 500 !important;
    color: var(--text) !important;
  }
  /* Rate and Amount cells */
  .boq-project-table td.boq-col-rate,
  .boq-project-table td.boq-col-amt {
    font-family: 'DM Mono', monospace !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    text-align: right !important;
  }
  .boq-project-table td.boq-col-amt {
    font-weight: 700 !important;
    color: var(--accent2) !important;
  }
  /* Remeasurement and Progress cells in spreadsheet row */
  .boq-project-table td.boq-col-orig-qty,
  .boq-project-table td.boq-col-act-qty,
  .boq-project-table td.boq-col-var {
    font-size: 11px !important;
    white-space: nowrap !important;
    text-align: right !important;
    font-family: 'DM Mono', monospace !important;
  }
  .boq-project-table td.boq-col-prev {
    font-size: 11px !important;
    white-space: nowrap !important;
    text-align: center !important;
    font-family: 'DM Mono', monospace !important;
    min-width: 85px !important;
    width: 85px !important;
  }
  .boq-project-table td.boq-col-this-ipa {
    font-size: 11px !important;
    white-space: nowrap !important;
    text-align: right !important;
    font-family: 'DM Mono', monospace !important;
    min-width: 110px !important;
    width: 110px !important;
  }
  .boq-project-table td.boq-col-progress {
    min-width: 220px !important;
    width: 220px !important;
    vertical-align: middle !important;
    overflow: visible !important;
    padding: 4px 6px !important;
  }
  .boq-progress-control-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 210px !important;
  }
  .boq-slider-track-wrap {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex: 1 1 auto !important;
    min-width: 100px !important;
  }
  .boq-stepper-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 28px !important;
    height: 28px !important;
    min-width: 32px !important;
    width: 32px !important;
    padding: 0 !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    background: var(--surface2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
    color: var(--text) !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    flex-shrink: 0 !important;
  }
  .boq-progress-val {
    font-size: 11px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
    min-width: 30px !important;
    text-align: right !important;
    font-family: 'DM Mono', monospace !important;
  }

  /* ──────────────────────────────────────────────────────────────
     6.  PHASE 2: QUICK PRICER SPREADSHEET TABLE
         Preserves tabular rows with smooth horizontal panning.
     ────────────────────────────────────────────────────────────── */
  .qp-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    background: var(--surface) !important;
  }
  .qp-table {
    display: table !important;
    min-width: 720px !important;
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
  }
  .qp-table colgroup {
    display: table-column-group !important;
  }
  .qp-table thead {
    display: table-header-group !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 5 !important;
    background: var(--surface2) !important;
  }
  .qp-table thead th {
    display: table-cell !important;
    padding: 8px 8px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    color: var(--text2) !important;
    border-bottom: 2px solid var(--border) !important;
  }
  .qp-table tbody {
    display: table-row-group !important;
  }
  .qp-table tbody tr {
    display: table-row !important;
    background: var(--surface) !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .qp-table tbody tr > td {
    display: table-cell !important;
    padding: 6px 8px !important;
    vertical-align: middle !important;
    border-top: 1px solid var(--border) !important;
    width: auto !important;
  }
  .qp-table tfoot {
    display: table-footer-group !important;
    position: sticky !important;
    bottom: 0 !important;
    background: var(--surface3) !important;
  }
  .qp-table tfoot tr {
    display: table-row !important;
    background: var(--surface3) !important;
  }
  .qp-table tfoot tr td {
    display: table-cell !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
    border-top: 2px solid var(--border) !important;
  }

  /* ──────────────────────────────────────────────────────────────
     BOQ BUILDER / CREATOR HORIZONTAL SPREADSHEET TABLE
     ────────────────────────────────────────────────────────────── */
  .boq-creator-items {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
  }
  .boq-creator-items table {
    min-width: 650px !important;
    width: 100% !important;
    border-collapse: collapse !important;
  }
  .boq-creator-bill-header,
  .boq-creator-element-header {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     PROJECT DETAILS: ACCORDION AND METRIC WRAP FIXES
     ────────────────────────────────────────────────────────────── */
  .mfe-header,
  div[style*="padding:10px 16px"][style*="background:var(--surface2)"][style*="cursor:pointer"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  div[style*="padding:10px 16px"][style*="background:var(--surface2)"][style*="cursor:pointer"] > div:first-child,
  .mfe-header > div:first-child {
    flex-wrap: wrap !important;
    gap: 6px !important;
    max-width: 100% !important;
  }
  div[style*="padding:10px 16px"][style*="background:var(--surface2)"][style*="cursor:pointer"] > div:last-child,
  .mfe-header > div:last-child {
    margin-left: auto !important;
  }
  div[style*="grid-template-columns:repeat(5,1fr)"],
  div[style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     7.  PHASE 2: RATE LIBRARY & RESOURCES TOUCH-CARD OVERHAUL
         Converts 13-column rate items into high-density touch cards
         with 44px tap targets for editing and details.
     ────────────────────────────────────────────────────────────── */
  #panel-library .table-wrap,
  #panel-resources .table-wrap {
    overflow-x: visible !important;
  }
  #rateTableHead,
  #importedRateTableHead,
  #matTableHead,
  #labTableHead,
  #panel-library thead,
  #panel-resources thead {
    display: none !important;
  }
  #panel-library table.data-table,
  #panel-resources table.data-table,
  #rateTableBody,
  #importedRateTableBody,
  #pendingRateBody,
  #matTableBody,
  #labTableBody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }
  /* Curated Rate Card */
  #rateTableBody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 8px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #rateTableBody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #rateTableBody > tr > td.sel-td-slot {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 2 !important;
  }
  #rateTableBody > tr > td:nth-child(2) {
    display: none !important;
  }
  #rateTableBody > tr > td:nth-child(3) {
    padding-right: 36px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
  }
  #rateTableBody > tr > td:nth-child(3) > div:first-child {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
  }
  #rateTableBody > tr > td:nth-child(4) {
    display: inline-block !important;
    width: auto !important;
  }
  #rateTableBody > tr > td:nth-child(5) {
    display: inline-block !important;
    width: auto !important;
    font-size: 11px !important;
    color: var(--accent2) !important;
    background: rgba(104, 211, 145, 0.12) !important;
    padding: 2px 8px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
  }
  /* Breakdown chips */
  #rateTableBody > tr > td:nth-child(6),
  #rateTableBody > tr > td:nth-child(7),
  #rateTableBody > tr > td:nth-child(8),
  #rateTableBody > tr > td:nth-child(9) {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    color: var(--text2) !important;
    padding: 2px 0 !important;
  }
  #rateTableBody > tr > td:nth-child(6)::before { content: "Materials:"; color: var(--text3); }
  #rateTableBody > tr > td:nth-child(7)::before { content: "Labour:"; color: var(--text3); }
  #rateTableBody > tr > td:nth-child(8)::before { content: "Plant:"; color: var(--text3); }
  #rateTableBody > tr > td:nth-child(9)::before { content: "Net Cost:"; color: var(--text3); }
  #rateTableBody > tr > td:nth-child(10) {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
  }
  #rateTableBody > tr > td:nth-child(10)::before { content: "Markup Margin:"; color: var(--text3); }
  #rateTableBody > tr > td:nth-child(11) {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 0 4px !important;
    border-top: 1px solid var(--border) !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
  }
  #rateTableBody > tr > td:nth-child(11)::before {
    content: "Final Rate:";
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
  }
  #rateTableBody > tr > td:nth-child(12) {
    padding: 2px 0 !important;
  }
  #rateTableBody > tr > td:nth-child(13) {
    border-top: 1px solid var(--border) !important;
    padding-top: 8px !important;
    margin-top: 4px !important;
  }
  #rateTableBody > tr > td:nth-child(13) .flex {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 10px !important;
  }
  #rateTableBody > tr > td:nth-child(13) button {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  /* Sentinel row */
  #rateTableBody > tr#rateTableSentinel,
  #rateTableSentinel {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 10px 0 !important;
    display: block !important;
    width: 100% !important;
  }
  #rateTableSentinel td {
    display: block !important;
    width: 100% !important;
    text-align: center !important;
  }

  /* Project Rate History Cards */
  #importedRateTableBody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 6px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #importedRateTableBody > tr:has(td[colspan]) {
    background: rgba(104, 211, 145, 0.12) !important;
    border-left: 4px solid var(--accent2) !important;
    border-radius: 8px !important;
    padding: 10px 12px !important;
  }
  #importedRateTableBody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #importedRateTableBody > tr > td.sel-td-slot {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 2 !important;
  }
  #importedRateTableBody > tr > td:nth-child(2) {
    display: none !important;
  }
  #importedRateTableBody > tr > td:nth-child(3) {
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #importedRateTableBody > tr > td:nth-child(4) {
    padding-right: 36px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text) !important;
  }
  #importedRateTableBody > tr > td:nth-child(7) {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
    padding: 6px 0 !important;
    border-top: 1px dashed var(--border) !important;
  }
  #importedRateTableBody > tr > td:nth-child(7)::before {
    content: "Learned Rate:";
    font-size: 12px;
    font-weight: 400;
    color: var(--text3);
  }
  #importedRateTableBody > tr > td:last-child {
    border-top: 1px solid var(--border) !important;
    padding-top: 8px !important;
    margin-top: 4px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
  }
  #importedRateTableBody > tr > td:last-child button {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* Materials & Labour Resources Cards */
  #matTableBody > tr,
  #labTableBody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 6px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #matTableBody > tr > td,
  #labTableBody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
  }
  #matTableBody > tr > td.sel-td-slot,
  #labTableBody > tr > td.sel-td-slot {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 2 !important;
  }
  #matTableBody > tr > td:nth-child(2),
  #labTableBody > tr > td:nth-child(2) {
    display: none !important;
  }
  #matTableBody > tr > td:nth-child(3),
  #labTableBody > tr > td:nth-child(3) {
    padding-right: 36px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
  }
  #matTableBody > tr > td.amount-cell,
  #matTableBody > tr > td:nth-child(6) {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
    padding: 6px 0 !important;
    border-top: 1px dashed var(--border) !important;
  }
  #matTableBody > tr > td.amount-cell::before,
  #matTableBody > tr > td:nth-child(6)::before {
    content: "Unit Cost:";
    font-size: 12px;
    font-weight: 400;
    color: var(--text3);
  }
  #matTableBody > tr > td:last-child,
  #labTableBody > tr > td:last-child {
    border-top: 1px solid var(--border) !important;
    padding-top: 8px !important;
    margin-top: 4px !important;
  }
  #matTableBody > tr > td:last-child .flex,
  #labTableBody > tr > td:last-child .flex {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 8px !important;
  }
  #matTableBody > tr > td:last-child button,
  #labTableBody > tr > td:last-child button {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     8.  PHASE 3: FULL-VIEWPORT EDGE-TO-EDGE PROJECT DETAIL WORKSPACE
         100vw × 100dvh full-bleed task screen on mobile devices,
         replacing cramped 24px desktop modal padding.
     ────────────────────────────────────────────────────────────── */
  #projectDetailOverlay {
    padding: 0 !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }
  #projectDetailOverlay .pd-inner-shell,
  #projectDetailOverlay > div {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }
  #projectDetailOverlay .pd-header {
    border-radius: 0 !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    padding-top: calc(8px + env(safe-area-inset-top)) !important;
    padding-left: max(10px, env(safe-area-inset-left)) !important;
    padding-right: max(10px, env(safe-area-inset-right)) !important;
    padding-bottom: 6px !important;
    background: var(--surface2) !important;
    border-bottom: 1px solid var(--border) !important;
  }
  #projectDetailOverlay .pd-id-row {
    padding: 4px 6px !important;
    gap: 8px !important;
    align-items: center !important;
  }
  #projectDetailOverlay .pd-title-col {
    min-width: 0 !important;
  }
  #projectDetailOverlay .pd-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }
  #projectDetailOverlay .pd-subtitle {
    font-size: 11px !important;
    margin-top: 2px !important;
  }
  #projectDetailOverlay .pd-close-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }
  #projectDetailOverlay .pd-strip-wrap {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding-bottom: 4px !important;
  }
  #projectDetailOverlay .pd-btn-strip {
    padding: 4px 6px !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
  }
  #projectDetailOverlay .pd-btn-strip .btn {
    min-height: 40px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }
  #projectDetailOverlay .pd-body-wrap {
    padding: 12px max(12px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)) !important;
    gap: 14px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 1 auto !important;
  }

  /* Project Details Summary KPI Strip Collapse (2 columns on phones) */
  #projectDetailOverlay .pd-kpi-grid,
  .pd-kpi-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .pd-kpi-grid .mini-kpi {
    padding: 10px 12px !important;
    min-width: 0 !important;
    overflow: hidden !important;
    border-radius: 8px !important;
    background: var(--surface2) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06) !important;
  }
  .pd-kpi-grid .mini-kpi .mini-kpi-label {
    font-size: 11px !important;
    white-space: normal !important;
    line-height: 1.25 !important;
    color: var(--text3) !important;
  }
  .pd-kpi-grid .mini-kpi .mini-kpi-value {
    font-size: 14px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-top: 3px !important;
  }

  /* Inter-Project Working Capital & Liquidity 4-tile strip collapse to 2 columns */
  .inter-funding-kpi-grid,
  [data-pd-section="interfunding"] div[style*="grid-template-columns:repeat(4,1fr)"] {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .inter-funding-kpi-grid > div,
  [data-pd-section="interfunding"] div[style*="grid-template-columns:repeat(4,1fr)"] > div {
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 10px 12px !important;
  }

  /* BOQ Smart Batch % Editor Toolbar wrap and touch sizes */
  [data-pd-section="boq"] div[style*="flex-wrap:wrap;gap:8px"] {
    gap: 8px !important;
  }
  [data-pd-section="boq"] div[style*="flex-wrap:wrap;gap:8px"] .btn {
    min-height: 40px !important;
    font-size: 12px !important;
  }

  /* Project Details Viewport & Horizontal Overflow Hardening */
  #projectDetailOverlay,
  #projectDetailOverlay .pd-inner-shell,
  #projectDetailOverlay .pd-body-wrap,
  #projectDetailOverlay [data-pd-section] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  #projectDetailOverlay .pd-body-wrap {
    overflow-x: hidden !important;
  }

  /* Universal Accordion & Section Header Wrap */
  #projectDetailOverlay [data-pd-section] > div > div[style*="justify-content:space-between"],
  #projectDetailOverlay .pd-accordion-header,
  #projectDetailOverlay .mfe-header,
  #projectDetailOverlay [data-pd-section] .u-row-between {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px 12px !important;
  }
  #projectDetailOverlay [data-pd-section] > div > div[style*="justify-content:space-between"] > div:first-child,
  #projectDetailOverlay .mfe-header > div:first-child,
  #projectDetailOverlay [data-pd-section] .u-row-between > div:first-child {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
  }
  #projectDetailOverlay [data-pd-section] > div > div[style*="justify-content:space-between"] > div:last-child,
  #projectDetailOverlay .mfe-header > div:last-child,
  #projectDetailOverlay [data-pd-section] .u-row-between > div:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
    flex: 1 1 100% !important;
    width: 100% !important;
  }
  #projectDetailOverlay [data-pd-section] .btn,
  #projectDetailOverlay [data-pd-section] .j360-btn {
    font-size: 11px !important;
    padding: 6px 10px !important;
    min-height: 36px !important;
    max-width: 100% !important;
  }

  /* Liquidated Damages 5-tile / 4-tile grid -> 2 columns */
  #projectDetailOverlay [data-pd-section="ld"] div[style*="grid-template-columns:repeat(5,1fr)"],
  #projectDetailOverlay [data-pd-section="ld"] div[style*="grid-template-columns:repeat(4,1fr)"],
  .ld-metrics-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  /* Minimum IPC Threshold Analytics 4-tile grid -> 2 columns */
  #projectDetailOverlay [id^="minIPCThreshold_"] div[style*="grid-template-columns:repeat(4,1fr)"],
  .ipc-threshold-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  /* BOQ IPA Summary Bar 4 tiles -> 2 columns */
  #projectDetailOverlay [id^="boqIPASummary_"] {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }
  #projectDetailOverlay [id^="boqIPASummary_"] > div {
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border-right: none !important;
  }

  /* BOQ Action Toolbar wrap */
  #projectDetailOverlay [data-pd-section="boq"] .u-row-between {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  #projectDetailOverlay [data-pd-section="boq"] .u-row-between > div:last-child {
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    justify-content: flex-start !important;
  }

  /* ──────────────────────────────────────────────────────────────
     9.  PHASE 3: MULTI-SECTION FORMS & STICKY STAGE HEADERS
         Sequential stacking of multi-column forms and sticky
         stage indicators during long modal scrolls.
     ────────────────────────────────────────────────────────────── */
  .j360-modal-body .modal-section-eyebrow,
  .j360-modal-body .modal-section-title {
    position: sticky !important;
    top: -16px !important;
    z-index: 8 !important;
    background: var(--surface2) !important;
    padding: 8px 12px !important;
    margin-left: -12px !important;
    margin-right: -12px !important;
    border-radius: 6px !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
  }
  .j360-modal-body .kpi-grid-3,
  .j360-modal-body .kpi-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     10. PHASE 3: WORK PROGRAMME NATIVE BOTTOM TASK SHEET
         Transform 360px desktop side drawer into mobile bottom sheet.
     ────────────────────────────────────────────────────────────── */
  #wpTaskEditor {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 90dvh !important;
    max-height: 90dvh !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    border-left: none !important;
    border-top: 1px solid var(--border) !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5) !important;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }
  #wpTaskEditor[style*="right: 0"],
  #wpTaskEditor[style*="right:0"] {
    transform: translateY(0) !important;
  }

  /* ──────────────────────────────────────────────────────────────
     11. PHASE 3: PROJECT CARD FOOTER & TOUCH SAFETY
         Safety spacing between action buttons on project cards
         to eliminate accidental deletion or mis-taps.
     ────────────────────────────────────────────────────────────── */
  .project-card .pcg-footer {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 14px !important;
    gap: 8px !important;
    border-top: 1px solid var(--border) !important;
  }
  .project-card .pcg-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .project-card .pcg-actions .btn {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 0 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .project-card .pcg-actions .btn-danger {
    margin-left: 6px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     12. PHASE 4: PROCUREMENT REQUISITIONS & PURCHASE ORDERS
         Transforms Material Requests, Purchase Orders, and Deliveries
         into status-coded touch cards with 44px tap targets.
     ────────────────────────────────────────────────────────────── */
  #panel-procurement .table-wrap,
  #mrRegisterCard .table-wrap,
  #poRegisterCard .table-wrap {
    overflow-x: visible !important;
  }
  #mrRegisterCard thead,
  #poRegisterCard thead {
    display: none !important;
  }
  #mrRegisterCard table.data-table,
  #mrRegisterCard table.data-table tbody,
  #poRegisterCard table.data-table,
  #poRegisterCard table.data-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }
  #mrRegisterCard table.data-table tbody > tr,
  #poRegisterCard table.data-table tbody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 8px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td,
  #poRegisterCard table.data-table tbody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  /* Hide sequential row number on touch cards */
  #mrRegisterCard table.data-table tbody > tr > td.row-num-td,
  #poRegisterCard table.data-table tbody > tr > td.row-num-td {
    display: none !important;
  }
  /* Status Badge positioned top-right */
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(6),
  #poRegisterCard table.data-table tbody > tr > td:nth-child(6) {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 2 !important;
  }
  /* Ref No. in bold brand accent */
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(2),
  #poRegisterCard table.data-table tbody > tr > td:nth-child(2) {
    order: 1 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--accent) !important;
    padding-right: 90px !important;
  }
  /* Item Description / Scope */
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(4),
  #poRegisterCard table.data-table tbody > tr > td:nth-child(4) {
    order: 2 !important;
    max-width: none !important;
    width: 100% !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(4) > div:first-child,
  #poRegisterCard table.data-table tbody > tr > td:nth-child(4) > div:first-child {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    line-height: 1.35 !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(4) > div:last-child,
  #poRegisterCard table.data-table tbody > tr > td:nth-child(4) > div:last-child {
    font-size: 11px !important;
    color: var(--text3) !important;
    margin-top: 3px !important;
  }
  /* Project Assignment */
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(5),
  #poRegisterCard table.data-table tbody > tr > td:nth-child(5) {
    order: 3 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 12px !important;
    color: var(--text2) !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(5)::before,
  #poRegisterCard table.data-table tbody > tr > td:nth-child(5)::before {
    content: "Project:";
    color: var(--text3);
    font-size: 11px;
    font-weight: 500;
  }
  /* Material Request specific dates & requester */
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(7) {
    order: 4 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 12px !important;
    padding: 6px 10px !important;
    background: var(--surface2) !important;
    border-radius: 6px !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(7)::before {
    content: "Needed By:";
    color: var(--text3);
    font-weight: 500;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(8) {
    order: 5 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(8)::before {
    content: "Requested By:";
    color: var(--text3);
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(3) {
    order: 6 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(3)::before {
    content: "Date Raised:";
    color: var(--text3);
  }
  /* Material Request Actions Bar */
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(9) {
    order: 7 !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    display: flex !important;
    gap: 8px !important;
    justify-content: stretch !important;
    width: 100% !important;
    text-align: left !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(9) .btn-primary {
    flex: 1 !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
    margin-right: 0 !important;
  }
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(9) .btn-secondary,
  #mrRegisterCard table.data-table tbody > tr > td:nth-child(9) .btn-danger {
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 0 !important;
  }

  /* Purchase Order specific cost & payment status */
  #poRegisterCard table.data-table tbody > tr > td:nth-child(8) {
    order: 4 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
    padding: 8px 12px !important;
    background: rgba(100, 200, 140, 0.08) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(100, 200, 140, 0.2) !important;
    font-family: 'DM Mono', monospace !important;
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(8)::before {
    content: "Total (incl. VAT):";
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    font-family: var(--font-sans);
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(9) {
    order: 5 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(9)::before {
    content: "Payment Status:";
    color: var(--text3);
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(7) {
    order: 6 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(7)::before {
    content: "Required By:";
    color: var(--text3);
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(3) {
    order: 7 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(3)::before {
    content: "Date Raised:";
    color: var(--text3);
  }
  /* Purchase Order Actions Bar */
  #poRegisterCard table.data-table tbody > tr > td:nth-child(10) {
    order: 8 !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    display: flex !important;
    gap: 8px !important;
    justify-content: stretch !important;
    width: 100% !important;
    text-align: left !important;
  }
  #poRegisterCard table.data-table tbody > tr > td:nth-child(10) .btn {
    flex: 1 !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 0 !important;
  }

  /* Goods Delivery Cards on Mobile */
  #deliveryRegisterCard div[style*="display:flex;gap:16px"] {
    flex-direction: column !important;
    padding: 14px 16px !important;
    gap: 12px !important;
  }
  #deliveryRegisterCard div[style*="display:flex;flex-direction:column;gap:6px;flex-shrink:0"] {
    width: 100% !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 10px !important;
  }
  #deliveryRegisterCard div[style*="display:flex;flex-direction:column;gap:6px;flex-shrink:0"] .btn {
    flex: 1 !important;
    min-height: 44px !important;
    min-width: 120px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ──────────────────────────────────────────────────────────────
     13. PHASE 4: PERSONNEL & HR ROSTER TOUCH-CARD OVERHAUL
         Converts 12-column employee roster, payroll registers,
         and leave logs into responsive touch cards with 44px taps.
     ────────────────────────────────────────────────────────────── */
  #panel-hr .table-wrap,
  #rosterRegisterCard .table-wrap,
  #payrollContent .table-wrap,
  #leaveContent .table-wrap {
    overflow-x: visible !important;
  }
  #hrRosterHead,
  #payrollContent table.data-table thead,
  #payrollContent table.data-table tfoot,
  #leaveContent table.data-table thead {
    display: none !important;
  }
  #panel-hr #hrRosterBody,
  #payrollContent table.data-table,
  #payrollContent table.data-table tbody,
  #leaveContent table.data-table,
  #leaveContent table.data-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    width: 100% !important;
  }
  /* HR Employee Card */
  #hrRosterBody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 8px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #hrRosterBody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #hrRosterBody > tr > td.sel-td-slot {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 2 !important;
  }
  #hrRosterBody > tr > td.row-num-td {
    display: none !important;
  }
  /* Employee Name & ID */
  #hrRosterBody > tr > td:nth-child(3) {
    order: 1 !important;
    padding-right: 44px !important;
    width: 100% !important;
  }
  #hrRosterBody > tr > td:nth-child(3) > div:first-child {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
  }
  #hrRosterBody > tr > td:nth-child(3) > div:nth-child(2) {
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  /* Classification & Type Badges */
  #hrRosterBody > tr > td:nth-child(6) {
    order: 2 !important;
    display: inline-flex !important;
    width: auto !important;
  }
  #hrRosterBody > tr > td:nth-child(7) {
    order: 2 !important;
    display: inline-flex !important;
    width: auto !important;
    margin-left: 6px !important;
  }
  /* Role & Department */
  #hrRosterBody > tr > td:nth-child(5) {
    order: 3 !important;
    font-size: 12px !important;
    color: var(--text2) !important;
    line-height: 1.4 !important;
  }
  /* Status Badge */
  #hrRosterBody > tr > td:nth-child(10) {
    order: 4 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
  }
  #hrRosterBody > tr > td:nth-child(10)::before {
    content: "Status:";
    color: var(--text3);
  }
  /* Assigned Project */
  #hrRosterBody > tr > td:nth-child(8) {
    order: 5 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 12px !important;
  }
  #hrRosterBody > tr > td:nth-child(8)::before {
    content: "Assigned Project:";
    color: var(--text3);
    font-size: 11px;
  }
  /* NIDA & NSSF */
  #hrRosterBody > tr > td:nth-child(4) {
    order: 6 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #hrRosterBody > tr > td:nth-child(4)::before {
    content: "NIDA / NSSF:";
    color: var(--text3);
  }
  /* Remuneration / Net Pay Box */
  #hrRosterBody > tr > td:nth-child(9) {
    order: 7 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
    padding: 8px 12px !important;
    background: rgba(100, 200, 140, 0.08) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(100, 200, 140, 0.2) !important;
    font-family: 'DM Mono', monospace !important;
  }
  #hrRosterBody > tr > td:nth-child(9)::before {
    content: "Remuneration / Net:";
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    font-family: var(--font-sans);
  }
  #hrRosterBody > tr > td:nth-child(11) {
    display: none !important;
  }
  /* Employee Card Actions */
  #hrRosterBody > tr > td:nth-child(12) {
    order: 8 !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    width: 100% !important;
  }
  #hrRosterBody > tr > td:nth-child(12) > div {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }
  #hrRosterBody > tr > td:nth-child(12) .btn {
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 10px !important;
  }

  /* Payroll Register Touch Cards */
  #payrollSummaryArea > div:first-child {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  #payrollContent table.data-table tbody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 8px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #payrollContent table.data-table tbody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  #payrollContent table.data-table tbody > tr > td.row-num-td {
    display: none !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(2) {
    order: 1 !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(2) .u-weight-semi {
    font-size: 14px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(3) {
    order: 2 !important;
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(4) {
    order: 3 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(4)::before {
    content: "Gross Salary:";
    color: var(--text3);
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(6) {
    order: 4 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(6)::before {
    content: "Emoluments:";
    color: var(--text3);
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(7) {
    order: 5 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    color: var(--danger) !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(7)::before {
    content: "TRA PAYE:";
    color: var(--text3);
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(8) {
    order: 6 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    color: var(--accent3) !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(8)::before {
    content: "NSSF (Employee):";
    color: var(--text3);
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(10) {
    order: 7 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: var(--accent2) !important;
    padding: 8px 12px !important;
    background: rgba(100, 200, 140, 0.08) !important;
    border-radius: 8px !important;
    border: 1px solid rgba(100, 200, 140, 0.2) !important;
    font-family: 'DM Mono', monospace !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(10)::before {
    content: "Net Pay:";
    font-size: 12px;
    font-weight: 600;
    color: var(--text3);
    font-family: var(--font-sans);
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(13) {
    order: 8 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    color: var(--accent) !important;
    font-family: 'DM Mono', monospace !important;
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(13)::before {
    content: "Total Employer Cost:";
    color: var(--text3);
    font-weight: 400;
    font-family: var(--font-sans);
  }
  #payrollContent table.data-table tbody > tr > td:nth-child(5),
  #payrollContent table.data-table tbody > tr > td:nth-child(9),
  #payrollContent table.data-table tbody > tr > td:nth-child(11),
  #payrollContent table.data-table tbody > tr > td:nth-child(12) {
    display: none !important;
  }
  #payrollContent table.data-table tbody > tr > td:last-child {
    order: 9 !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    display: flex !important;
  }
  #payrollContent table.data-table tbody > tr > td:last-child .btn {
    width: 100% !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
  }
  #payrollContent table.data-table tbody > tr > td:last-child .btn::after {
    content: " View Payslip";
    margin-left: 6px;
  }

  /* Leave Register Cards */
  #leaveContent table.data-table tbody > tr {
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    padding: 14px 16px !important;
    gap: 8px !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08) !important;
  }
  #leaveContent table.data-table tbody > tr > td {
    padding: 0 !important;
    border: none !important;
    width: 100% !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(1) {
    order: 1 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    padding-right: 90px !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(6) {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 2 !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(2) {
    order: 2 !important;
    font-size: 12px !important;
    color: var(--text2) !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(2)::before {
    content: "Leave Type: ";
    color: var(--text3);
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(3) {
    order: 3 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 11px !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(3)::before {
    content: "From Date:";
    color: var(--text3);
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(4) {
    order: 4 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 11px !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(4)::before {
    content: "To Date:";
    color: var(--text3);
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(5) {
    order: 5 !important;
    display: flex !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    font-weight: 700 !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(5)::before {
    content: "Duration:";
    color: var(--text3);
    font-weight: 400;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(7) {
    order: 6 !important;
    font-size: 11px !important;
    color: var(--text3) !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(8) {
    order: 7 !important;
    border-top: 1px solid var(--border) !important;
    padding-top: 10px !important;
    margin-top: 4px !important;
    display: flex !important;
    gap: 8px !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(8) > div {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
  }
  #leaveContent table.data-table tbody > tr > td:nth-child(8) .btn {
    flex: 1 !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Statutory Returns Cards Collapse */
  #returnsComplianceCards > div {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* ──────────────────────────────────────────────────────────────
     14. PHASE 4: 12-MONTH ROLLING CASHFLOW FORECAST
         Sticky metric header column prevents horizontal disorientation
         when panning across monthly disbursements on mobile.
     ────────────────────────────────────────────────────────────── */
  #cfForecastTableBody .row-num-th,
  #cfForecastTableBody .row-num-td,
  #cfGlobalBody .row-num-th,
  #cfGlobalBody .row-num-td {
    display: none !important;
  }
  #cfForecastTableBody th:nth-child(2),
  #cfForecastTableBody td:nth-child(2),
  #cfGlobalBody th:nth-child(2),
  #cfGlobalBody td:nth-child(2) {
    position: sticky !important;
    left: 0 !important;
    z-index: 4 !important;
    background: var(--surface2) !important;
    box-shadow: 3px 0 8px rgba(0, 0, 0, 0.25) !important;
    padding-left: 12px !important;
    padding-right: 14px !important;
  }
  #cfForecastTableBody thead th:nth-child(2),
  #cfGlobalBody thead th:nth-child(2) {
    background: var(--surface3) !important;
    z-index: 5 !important;
  }
  #cfForecastTableBody tfoot td:nth-child(2),
  #cfGlobalBody tfoot td:nth-child(2) {
    background: var(--surface3) !important;
    z-index: 5 !important;
  }
  /* Bottom metric summary tiles in forecast */
  #cfForecastTableBody > div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

} /* end @media (max-width: 768px) */
