﻿/* Mobile Responsive Styles for BOMcraft */

/* Mobile First Approach */
@media (max-width: 768px) {
  /* Global mobile adjustments */
  body {
    font-size: 14px;
    overflow: hidden !important; /* Prevent body scroll on mobile */
    height: 100vh;
  }
  
  /* App content adjustments for mobile */
  .app-content {
    flex-direction: column;
    height: 100vh;
    overflow: hidden !important;
  }
  
  /* Hide sidebar on mobile */
  .sidebar-format {
    position: fixed;
    left: -100%;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
  }
  
  .sidebar-format.mobile-open {
    left: 0;
  }

  /* Hide sidebar bell icon on mobile (top header bell icon remains visible) */
  #sidebar-notification-btn {
    display: none !important;
  }
  
  /* Mobile menu toggle button */
  .mobile-menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: #581c87;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Mobile close button */
  .mobile-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1002;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  
  /* Main content adjustments */
  main {
    margin-left: 0 !important;
    padding-left: 0.5rem !important;        /* Minor gap on sides */
    padding-right: 0.5rem !important;       /* Minor gap on sides */
    padding-top: 3.5rem !important;         /* Space for mobile menu button */
    padding-bottom: 1rem !important;        /* Breathing room at bottom */
    overflow-y: auto !important; /* Enable scrolling on mobile */
    overflow-x: hidden !important; /* Prevent horizontal scroll on mobile */
    flex: 1;
    height: 100%;
    max-height: 100vh;
    -webkit-overflow-scrolling: touch;
  }

  /* Remove extra space above module titles on mobile */
  main > section {
    margin-top: 0 !important;
  }

  /* Hide main Module headings subtitles on mobile, except dashboard and accounts */
  main section:not(#dashboard):not(#accounts) h1 + p {
    display: none !important;
  }

  #dashboard p.text-gray-600,
  #accounts p.text-gray-600 {
    display: block !important;
  }

  /* Reduce heading container bottom margins on mobile */
  main section > div.mb-8,
  main section > div.mb-6,
  main section > div.flex.justify-between.items-center.mb-8 {
    margin-bottom: 1rem !important;
  }

  /* BOM Import button hidden on mobile (export remains visible) */
  .bom-import-btn {
    display: none !important;
  }
  
  /* Section headers */
  section > h1 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  /* Table responsiveness */
  .overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  table {
    min-width: 600px; /* Force horizontal scroll on small screens */
  }
  
  /* Accounts mobile adjustments */
  /* Button row: allow wrapping into 2 rows so all buttons are visible */
  #accounts > div.flex.justify-between.items-center {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  #accounts > div.flex.justify-between.items-center .flex.items-center.gap-3.flex-wrap {
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
  }

  #accounts > div.flex.justify-between.items-center .flex.items-center.gap-3.flex-wrap > * {
    flex: 1 1 auto;
    min-width: calc(50% - 0.25rem);
    max-width: calc(50% - 0.25rem);
    white-space: nowrap;
    text-align: center;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    font-size: 0.8rem !important;
  }

  #accounts table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  #accounts table th,
  #accounts table td {
    white-space: normal;
    word-break: break-word;
  }

  /* Hide drag-handle column (1st) on mobile — show only Name, Balance, Actions */
  #accounts table th:nth-child(1),
  #accounts table td:nth-child(1) {
    display: none;
  }

  /* Hide Type column (3rd) on mobile — keep Name (2nd), Balance (4th), Actions (5th) */
  #accounts table th:nth-child(3),
  #accounts table td:nth-child(3) {
    display: none;
  }

  /* Column widths for the 3 visible columns: Name / Balance / Actions */
  #accounts table th:nth-child(2),
  #accounts table td:nth-child(2) {
    width: 40%;
  }

  #accounts table th:nth-child(4),
  #accounts table td:nth-child(4) {
    width: 30%;
  }

  #accounts table th:nth-child(5),
  #accounts table td:nth-child(5) {
    width: 30%;
  }

  #accounts table td.table-cell-actions {
    padding-right: 0.75rem;
  }

  #accounts .overflow-x-auto {
    overflow-x: hidden;
    padding: 0 !important;
  }
  
  /* Form adjustments */
  .form-input, .form-select, .form-file-input {
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  /* Modal adjustments */
  .modal-content, .modal-content-lg {
    margin: 0 !important;
    padding: 1.5rem;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100vh !important;
    overflow-y: auto;
    border-radius: 0 !important;
  }
  
  /* Mobile scrollable products/materials sections - smaller max-height and sticky header */
  .modal-content form .border.border-gray-200.rounded-lg.p-4.bg-gray-50 {
    max-height: 35vh !important;
    overflow-y: auto !important;
    position: relative !important;
    padding-top: 1rem !important;
  }

  .modal-content form .border.border-gray-200.rounded-lg.p-4.bg-gray-50 > div.flex.justify-between.items-center.mb-3 {
    position: sticky !important;
    top: -1.05rem !important;
    z-index: 10 !important;
    background: #f9fafb !important; /* Matches bg-gray-50 */
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    margin-top: -1.05rem !important;
    margin-bottom: 0.75rem !important;
    border-bottom: 1px solid #e5e7eb !important;
  }

  /* Purchase modal mobile fields and grids */
  #purchase-modal .modal-content .form-input,
  #purchase-modal .modal-content .form-select,
  #purchase-modal .modal-content .form-file-input {
    width: 100% !important;
    min-width: 0;
  }

  /* ===== Purchase Form Mobile Layout =====
     Line 1: Date (col 1) + Account (col 2)
     Line 2: Supplier (full width)
     Line 3: Contact (full width)
     Line 4: Materials section (full width)
     Line 5: Total Amount (col 1) + Amount Paid (col 2)
     Line 6: Checkboxes / other children
  ===== */

  /* Make #purchase-form a 2-column grid so we can place each field precisely */
  #purchase-form {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
    align-items: start !important;
  }

  /* Dissolve the wrapper divs into the parent grid
     so their children become direct grid items */
  #purchase-top-row {
    grid-column: 1 / -1 !important;
    display: contents !important;
  }

  #purchase-bottom-row {
    grid-column: 1 / -1 !important;
    display: contents !important;
  }

  /* Date — col 1, row 1 */
  #purchase-top-row > div:has(#purchase-date) {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }

  /* Account — col 2, row 1 (same row as Date) */
  #purchase-bottom-row > div:has(#purchase-account) {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  /* Supplier — col 1/-1, row 2 */
  #purchase-top-row > div:has(#purchase-supplier) {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
  }

  /* Contact — col 1/-1, row 3 */
  #purchase-top-row > div:has(#purchase-contact) {
    grid-column: 1 / -1 !important;
    grid-row: 3 !important;
  }

  /* Materials section — col 1/-1, row 4 */
  #purchase-form > div:has(#purchase-materials-container) {
    grid-column: 1 / -1 !important;
    grid-row: 4 !important;
  }

  /* Total Amount — col 1, row 5 */
  #purchase-bottom-row > div:has(#purchase-amount) {
    grid-column: 1 !important;
    grid-row: 5 !important;
  }

  /* Amount Paid — col 2, row 5 */
  #purchase-bottom-row > div:has(#purchase-paid-amount) {
    grid-column: 2 !important;
    grid-row: 5 !important;
  }

  /* Checkboxes row and any remaining direct children — row 6+ */
  #purchase-form > div.flex.flex-wrap {
    grid-column: 1 / -1 !important;
    grid-row: 6 !important;
  }

  /* Hidden sections (freight, bill upload) — row 7 */
  #purchase-form > div[id]:not(#purchase-top-row):not(#purchase-bottom-row):not(#purchase-materials-container) {
    grid-column: 1 / -1 !important;
  }

  /* All inputs/selects fill their grid cell */
  #purchase-top-row .form-input,
  #purchase-top-row .form-select,
  #purchase-bottom-row .form-input,
  #purchase-bottom-row .form-select {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* Neutralize Tailwind space-y-4 margin-top on grid children
     (display:contents dissolves top/bottom rows, their children become
      direct grid items of #purchase-form which already has gap) */
  #purchase-form > * + *,
  #purchase-top-row > * + *,
  #purchase-bottom-row > * + * {
    margin-top: 0 !important;
  }

  /* Supplier autocomplete dropdown — keep it relative to its own div */
  #purchase-top-row > div:has(#purchase-supplier) {
    position: relative !important;
  }

  /* 3 & 4. Dynamic Material rows: Material + Delete on Row 1, Qty + Rate + Amount on Row 2 */
  #purchase-materials-container > div[id^="purchase-row-"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr auto !important;
    grid-template-rows: auto auto !important;
    gap: 0.5rem !important;
    align-items: end !important;
    padding: 0.75rem !important;
  }

  /* Material name spans the first row except the last cell */
  #purchase-materials-container > div[id^="purchase-row-"] > div:nth-child(1) {
    grid-column: 1 / span 3 !important;
    grid-row: 1 !important;
    width: 100% !important;
  }

  /* Delete button / spacer on the first row, last column */
  #purchase-materials-container > div[id^="purchase-row-"] > button,
  #purchase-materials-container > div[id^="purchase-row-"] > div:nth-child(5) {
    grid-column: 4 !important;
    grid-row: 1 !important;
    width: auto !important;
    min-width: unset !important;
    justify-self: end !important;
    align-self: end !important;
    margin-bottom: 0.25rem !important;
    padding: 0.5rem !important;
  }

  /* Qty, Rate, Amount on Row 2 */
  #purchase-materials-container > div[id^="purchase-row-"] > div:nth-child(2) {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }

  #purchase-materials-container > div[id^="purchase-row-"] > div:nth-child(3) {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }
  #purchase-materials-container > div[id^="purchase-row-"] > div:nth-child(4) {
    grid-column: 3 / span 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }

  /* ===== Sale Modal Mobile Layout Upgrades ===== */

  /* Header rearrangement: Title/Close on Row 1, Toggle centered on Row 2 */
  #sale-modal .modal-content > div:first-of-type {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-rows: auto auto !important;
    gap: 0.75rem !important;
    align-items: center !important;
  }

  #sale-modal-title {
    grid-column: 1 !important;
    grid-row: 1 !important;
    font-size: 1.25rem !important;
    word-break: keep-all !important;
  }

  #sale-modal .modal-content > div:first-of-type > button {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: end !important;
  }

  /* Improved centered mobile toggle */
  #sale-mode-toggle {
    grid-column: 1 / span 2 !important;
    grid-row: 2 !important;
    justify-self: center !important;
    margin: 0.25rem 0 !important;
    width: 300px !important; /* Narrower to fit within mobile screen bounds */
    height: 36px !important;
  }

  #sale-mode-toggle .sale-toggle-slider {
    width: 56px !important;
    height: 30px !important;
  }

  #sale-mode-toggle.mode-mix      .sale-toggle-slider { transform: translateX(0) !important; }
  #sale-mode-toggle.mode-product  .sale-toggle-slider { transform: translateX(60px) !important; }
  #sale-mode-toggle.mode-material .sale-toggle-slider { transform: translateX(120px) !important; }
  #sale-mode-toggle.mode-resell   .sale-toggle-slider { transform: translateX(180px) !important; }
  #sale-mode-toggle.mode-service  .sale-toggle-slider { transform: translateX(240px) !important; }

  #sale-mode-toggle .sale-toggle-label {
    font-size: 0 !important;
    width: 20% !important;
    line-height: 30px !important;
  }

  #sale-mode-toggle #label-mix::after {
    content: "Mix";
    font-size: 11px !important;
  }
  #sale-mode-toggle #label-prod::after {
    content: "P";
    font-size: 11px !important;
  }
  #sale-mode-toggle #label-mat::after {
    content: "M";
    font-size: 11px !important;
  }
  #sale-mode-toggle #label-resell::after {
    content: "Rsl";
    font-size: 11px !important;
  }
  #sale-mode-toggle #label-service::after {
    content: "Ser";
    font-size: 11px !important;
  }

  #sale-modal .modal-content .form-input,
  #sale-modal .modal-content .form-select,
  #sale-modal .modal-content .form-file-input {
    width: 100% !important;
    min-width: 0;
  }

  /* 1. Date and Account in single line with 35% and 65% space */
  #sale-modal .modal-content #sale-form > div:has(#sale-date) {
    display: grid !important;
    grid-template-columns: 3.5fr 6.5fr !important;
    gap: 0.75rem !important;
    width: 100% !important;
  }

  #sale-modal .modal-content #sale-form > div:has(#sale-date) > div {
    width: 100% !important;
  }

  /* 2. Resell: Customer Order — 6-col base grid on mobile */
  #sale-modal .modal-content .resell-customer-card {
    overflow: hidden !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid > div:nth-child(1) { /* Reselling Item — full row */
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid > div:nth-child(2) { /* Qty */
    grid-column: span 2 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid > div:nth-child(3) { /* S.Price */
    grid-column: span 2 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid > div:nth-child(4) { /* Delivery */
    grid-column: span 2 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid > div:nth-child(5) { /* Amount */
    grid-column: span 3 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-customer-grid.grid > div:nth-child(6) { /* Received */
    grid-column: span 3 !important;
    min-width: 0 !important;
  }

  /* 3. Resell: Supplier Details — clean 2-col grid on mobile */
  #sale-modal .modal-content .resell-supplier-card {
    overflow: hidden !important;
  }

  #sale-modal .modal-content .resell-supplier-grid.grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  #sale-modal .modal-content .resell-supplier-grid.grid > div:nth-child(1) { /* Supplier Name — full row */
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-supplier-grid.grid > div:nth-child(2) { /* Acc Paid */
    grid-column: span 1 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-supplier-grid.grid > div:nth-child(3) { /* Rate */
    grid-column: span 1 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-supplier-grid.grid > div:nth-child(4) { /* Bill */
    grid-column: span 1 !important;
    min-width: 0 !important;
  }

  #sale-modal .modal-content .resell-supplier-grid.grid > div:nth-child(5) { /* Paid */
    grid-column: span 1 !important;
    min-width: 0 !important;
  }

  /* Ensure all inputs/selects inside resell grids fill their cell */
  #sale-modal .modal-content .resell-customer-grid .form-input,
  #sale-modal .modal-content .resell-customer-grid .form-select,
  #sale-modal .modal-content .resell-supplier-grid .form-input,
  #sale-modal .modal-content .resell-supplier-grid .form-select {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  /* resell modal mobile labels */
  #sale-modal .modal-content label[for="resell-sale-rate"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-sale-rate"]::after { content: "S.Price" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-delivery-charges"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-delivery-charges"]::after { content: "Delivery" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-sale-total"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-sale-total"]::after { content: "Amount" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-amount-received"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-amount-received"]::after { content: "Received" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-supplier-account"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-supplier-account"]::after { content: "Acc Paid" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-purchase-rate"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-purchase-rate"]::after { content: "Rate" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-purchase-total"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-purchase-total"]::after { content: "Bill" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="resell-amount-paid"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="resell-amount-paid"]::after { content: "Paid" !important; font-size: 0.75rem !important; }

  /* Customer details mobile labels hidden and compact spacing */
  #sale-modal .modal-content #sale-customer-section {
    margin-top: 0.5rem !important;
  }
  #sale-modal .modal-content #sale-customer-details-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.35rem !important;
    margin-top: 0.25rem !important;
  }
  #sale-modal .modal-content #sale-customer-details-row > div {
    margin: 0 !important;
    padding: 0 !important;
  }
  #sale-modal .modal-content #sale-customer-details-row label {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
  }
  #sale-modal .modal-content #sale-customer-details-row input {
    margin: 0 !important;
  }

  /* Product/Material modal mobile labels */
  #sale-modal .modal-content label[for="sale-delivery-charges"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="sale-delivery-charges"]::after { content: "Delivery" !important; font-size: 0.75rem !important; }

  #sale-modal .modal-content label[for="sale-received"] { font-size: 0 !important; }
  #sale-modal .modal-content label[for="sale-received"]::after { content: "Received" !important; font-size: 0.75rem !important; }

  /* ===== Sale Product Row — Mobile Layout =====
     Row 1 : Item Name (full width) + Delete button
     Row 2 : Description + Qty (side by side)
     Row 3 : Price + Amount (side by side)
  ===== */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto !important;
    grid-template-rows: auto auto auto !important;
    gap: 0.5rem !important;
    align-items: center !important;
    padding: 0.75rem !important;
  }

  /* Reset default margins/paddings on row child divs and align to center */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > div {
    margin: 0 !important;
    padding: 0 !important;
    justify-content: center !important;
    height: 100% !important;
  }

  /* Hidden type input (child 1) — take no space */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > input[type="hidden"] {
    display: none !important;
  }

  /* Item name (child 2 / div:nth-child(2)) — Row 1, spans col 1-2 */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > div:nth-child(2) {
    grid-column: 1 / span 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
  }

  /* Delete button — Row 1, col 3 */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > button {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: auto !important;
    min-width: unset !important;
    justify-self: end !important;
    align-self: center !important;
    padding: 0.5rem !important;
    margin-bottom: 0 !important;
  }

  /* Description (child 3) — Row 2, col 1 */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > div:nth-child(3) {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }

  /* Qty (child 4) — Row 2, col 2 */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > div:nth-child(4) {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }

  /* Price (child 5) — Row 3, col 1 */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > div:nth-child(5) {
    grid-column: 1 !important;
    grid-row: 3 !important;
    width: 100% !important;
  }

  /* Amount (child 6) — Row 3, col 2 */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] > div:nth-child(6) {
    grid-column: 2 !important;
    grid-row: 3 !important;
    width: 100% !important;
  }

  /* Ensure all inputs fill their cell width and have a matching fixed height of 44px */
  #sale-modal .modal-content #sale-products-container > div[id^="sale-row-"] .form-input {
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    box-sizing: border-box !important;
  }

  /* ===== Packing / Additional Materials Row — Mobile Layout =====
     Row 1 : Material name (full width) + Delete button
     Row 2 : Qty + Cost Charged (side by side)
  ===== */
  #sale-modal .modal-content #additional-materials-container > div[id^="additional-material-row-"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr auto !important;
    grid-template-rows: auto auto !important;
    gap: 0.5rem !important;
    align-items: center !important;
    padding: 0.5rem 0 !important;
  }

  /* Reset default margins/paddings on row child divs to prevent misalignment */
  #sale-modal .modal-content #additional-materials-container > div[id^="additional-material-row-"] > div {
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Material name (div:nth-child(1)) — Row 1, col 1-2 */
  #sale-modal .modal-content #additional-materials-container > div[id^="additional-material-row-"] > div:nth-child(1) {
    grid-column: 1 / span 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
  }

  /* Delete button — Row 1, col 3 */
  #sale-modal .modal-content #additional-materials-container > div[id^="additional-material-row-"] > button {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: auto !important;
    min-width: unset !important;
    justify-self: end !important;
    align-self: center !important;
    padding: 0.5rem !important;
    margin-bottom: 0 !important;
  }

  /* Qty (div:nth-child(2)) — Row 2, col 1 */
  #sale-modal .modal-content #additional-materials-container > div[id^="additional-material-row-"] > div:nth-child(2) {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }

  /* Cost Charged (div:nth-child(3)) — Row 2, col 2 */
  #sale-modal .modal-content #additional-materials-container > div[id^="additional-material-row-"] > div:nth-child(3) {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
  }

  /* Ensure all inputs fill their cell and have a matching fixed height of 44px */
  #sale-modal .modal-content #additional-materials-container .form-input {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    box-sizing: border-box !important;
  }

  /* 5. Delivery charges, discount, total amount, received in 2 lines (2 columns) */
  #sale-modal .modal-content #sale-form > div:has(#sale-delivery-charges) {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  /* Keep it hidden when JS adds .hidden (e.g. in Resell mode) */
  #sale-modal .modal-content #sale-form > div:has(#sale-delivery-charges).hidden {
    display: none !important;
  }

  #sale-modal .modal-content #sale-form > div:has(#sale-delivery-charges) > div {
    width: 100% !important;
  }

  /* ===== Purchase section — mobile layout ===== */
  #purchase-purchases > div:first-of-type {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem !important;
  }

  #purchase-purchases > div:first-of-type > div:first-child {
    width: 100%;
  }

  #purchase-purchases > div:first-of-type > div.flex.items-center.gap-3 {
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    width: 100% !important;
  }

  #purchases-search-toggle-btn {
    order: 1 !important;
    flex: 0 0 auto !important;
  }

  #purchases-filter-wrapper {
    order: 2 !important;
    position: relative !important;
    width: 2.5rem !important;
    height: 2.5rem !important;
    flex: 0 0 2.5rem !important;
  }

  #purchases-status-filter {
    opacity: 0 !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 10 !important;
    cursor: pointer !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  .mobile-purchases-filter-icon-btn {
    display: flex !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: #ffffff !important;
    border: 2px solid #ddd6fe !important;
    color: #581c87 !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
    z-index: 5 !important;
  }

  .mobile-purchases-filter-icon-btn.active {
    background-color: #7c3aed !important;
    color: #ffffff !important;
    border-color: #7c3aed !important;
  }

  #purchase-purchases > div:first-of-type > div.flex.items-center.gap-3 > button.purchase-export-btn,
  #purchase-purchases > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="Export"] {
    order: 3 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #purchase-purchases > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="showPurchaseModal"] {
    order: 4 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #purchase-purchases #purchases-search {
    max-width: 100%;
  }

  /* Purchase export button — visible on mobile */

  /* Strip the outer table-wrapper box on mobile */
  #purchase-purchases > div:nth-of-type(2) {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip the pagination bar outer box */
  #purchases-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  /* Purchases table as mobile cards */
  #purchase-purchases table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #purchase-purchases thead {
    display: none;
  }

  #purchase-purchases tbody {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
  }

  #purchase-purchases tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 0;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }

  #purchase-purchases td {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    font-size: 12px;
    border-bottom: 1px solid #f3f4f6;
    gap: 0.15rem;
  }

  #purchase-purchases td:last-child {
    border-bottom: 0;
  }

  /* Pseudo-label above each value */
  #purchase-purchases td::before {
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
  }

  /* --- Row 1: Supplier (Left) & Date (Right) in single line --- */
  #purchase-purchases td:nth-child(2) {
    grid-column: 1 / 3;
    order: 1;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    padding: 0.625rem 0.5rem 0.625rem 0.875rem;
    border-bottom: none;
    border-right: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #purchase-purchases td:nth-child(2)::before {
    content: "Supplier";
    color: rgba(255, 255, 255, 0.75);
  }

  #purchase-purchases td:nth-child(1) {
    grid-column: 3 / 4;
    order: 2;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 11.5px;
    padding: 0.625rem 0.625rem 0.625rem 0.25rem;
    text-align: right;
    align-items: flex-end;
    border-bottom: none;
    white-space: nowrap !important;
  }

  #purchase-purchases td:nth-child(1)::before {
    content: "Date";
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap !important;
  }

  /* --- Material (full width row) --- */
  #purchase-purchases td:nth-child(3) {
    grid-column: 1 / -1;
    order: 3;
    color: #4b5563;
    font-size: 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 0.45rem 0.875rem;
  }

  #purchase-purchases td:nth-child(3)::before {
    content: "Material";
  }

  /* --- Row 2: Amount, Paid, Balance in single line --- */
  #purchase-purchases td:nth-child(4)::before { content: "Amount"; font-size: 9.5px; white-space: nowrap !important; }
  #purchase-purchases td:nth-child(5)::before { content: "Paid"; font-size: 9.5px; white-space: nowrap !important; }
  #purchase-purchases td:nth-child(6)::before { content: "Balance"; font-size: 9.5px; white-space: nowrap !important; }

  #purchase-purchases td:nth-child(4) {
    grid-column: 1 / 2;
    order: 4;
    color: #1f2937;
    font-weight: 700;
    font-size: 11px;
    padding: 0.45rem 0.35rem;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #purchase-purchases td:nth-child(5) {
    grid-column: 2 / 3;
    order: 5;
    color: #16a34a;
    font-weight: 600;
    font-size: 11px;
    padding: 0.45rem 0.35rem;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #purchase-purchases td:nth-child(6) {
    grid-column: 3 / 4;
    order: 6;
    color: #dc2626;
    font-weight: 600;
    font-size: 11px;
    padding: 0.45rem 0.35rem;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Row 3: Status & Actions in single line --- */
  #purchase-purchases td:nth-child(7) {
    grid-column: 1 / 2;
    order: 7;
    background: #f9fafb;
    border-bottom: 0;
    padding: 0.5rem 0.75rem;
    justify-content: center;
    align-items: flex-start;
  }

  #purchase-purchases td:nth-child(7)::before {
    display: none;
  }

  #purchase-purchases td:nth-child(8) {
    grid-column: 2 / 4;
    order: 8;
    background: #f9fafb;
    border-bottom: 0;
    padding: 0.5rem 0.75rem;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
  }

  #purchase-purchases td:nth-child(8)::before {
    display: none;
  }

  #purchase-purchases td:nth-child(8) button {
    width: auto !important;
    min-height: unset;
    padding: 0.375rem 0.625rem !important;
    font-size: 12px;
    border-radius: 0.5rem;
  }

  /* --- Row 3: Order Status & Payment & Actions --- */
  #sale-sales td:nth-child(8) {
    grid-column: 1 / 2;
    order: 7;
    background: #f9fafb;
    border-bottom: 0;
    padding: 0.5rem 0.75rem;
    justify-content: center;
    align-items: flex-start;
  }

  #sale-sales td:nth-child(8)::before {
    content: "Order Status";
  }

  #sale-sales td:nth-child(8) select {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-size: 12px !important;
    padding: 0.375rem 0.5rem !important;
    border-radius: 0.5rem !important;
    box-sizing: border-box !important;
  }

  #sale-sales td:nth-child(9) {
    grid-column: 2 / 3;
    order: 8;
    background: #f9fafb;
    border-bottom: 0;
    border-left: none;
    padding: 0.5rem 0.75rem;
    justify-content: center;
    align-items: flex-start;
  }

  #sale-sales td:nth-child(9)::before {
    content: "Payment";
  }

  #sale-sales td:nth-child(10) {
    grid-column: 3 / 4;
    order: 9;
    background: #f9fafb;
    border-bottom: 0;
    border-left: none;
    padding: 0.5rem 0.75rem;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
  }

  #sale-sales td:nth-child(10)::before {
    display: none;
  }

  #sale-sales td:nth-child(10) button {
    width: auto !important;
    min-height: unset;
    padding: 0.375rem 0.625rem !important;
    font-size: 12px;
    border-radius: 0.5rem;
  }

  /* Inventory section mobile layout */
  #inventory > div:first-of-type {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem !important;
  }

  #inventory > div:first-of-type > div:first-child {
    width: 100%;
  }

  #inventory > div:first-of-type > div.flex.items-center.gap-3 {
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    width: 100% !important;
    overflow-x: auto !important;
  }

  #inventory-search-toggle-btn {
    order: 1 !important;
    flex: 0 0 auto !important;
  }

  #inventory > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="Export"],
  #inventory > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="export"] {
    order: 2 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.35rem !important;
    font-size: 11px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #inventory > div:first-of-type > div.flex.items-center.gap-3 > button.inventory-add-btn,
  #inventory > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="showAdd"] {
    order: 3 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.35rem !important;
    font-size: 11px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #inventory > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="showAdjustmentModal"] {
    order: 4 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.35rem !important;
    font-size: 11px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  /* Inventory export button — visible on mobile */

  #inventory #inventory-search {
    max-width: 100%;
  }

  /* Strip the outer table-wrapper box on mobile */
  #inv-panel-inventory > div:first-of-type {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip the pagination bar outer box */
  #inventory-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  /* ===== Inventory Cards on Mobile (visually matches Product BOM) ===== */
  #inv-panel-inventory table {
    width: 100%;
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  #inv-panel-inventory thead {
    display: none;
  }

  #inv-panel-inventory tr {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-bottom: 1.125rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
  }

  /* Header Cell (Material Name + Retail + Low Stock + Actions) */
  #inv-panel-inventory td:nth-child(1),
  #inventory td.inv-header-cell {
    grid-column: 1 / -1;
    display: flex !important;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100% !important;
    box-sizing: border-box !important;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    padding: 0.75rem 0.875rem !important;
    border: none !important;
    color: #ffffff !important;
  }
  #inv-panel-inventory td:nth-child(1)::before,
  #inventory td.inv-header-cell::before {
    display: none !important;
  }

  /* Title text on purple header */
  #inventory .inv-material-title {
    color: #ffffff !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  }

  /* Retail badge on purple header */
  #inventory .inv-retail-badge {
    color: #fef08a !important;
    background: rgba(0, 0, 0, 0.22) !important;
    border: 1px solid rgba(254, 240, 138, 0.35) !important;
    font-weight: 700 !important;
  }

  /* Low stock limit text on purple header */
  #inventory .inv-limit-text {
    color: rgba(255, 255, 255, 0.92) !important;
    font-size: 0.775rem !important;
  }
  #inventory .inv-limit-text span {
    color: #ffffff !important;
    font-weight: 700 !important;
  }

  /* Placeholder icon on purple header */
  #inventory td.inv-header-cell .bg-gray-50 {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: #ffffff !important;
  }
  #inventory td.inv-header-cell .bg-gray-50 i,
  #inventory td.inv-header-cell .bg-gray-50 svg {
    color: #ffffff !important;
  }

  /* Frosted Action buttons inside title header box */
  .inv-header-actions button {
    width: auto !important;
    min-height: unset !important;
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.45) !important;
    border-radius: 0.5rem;
    padding: 0.35rem 0.6rem !important;
    font-size: 11.5px;
    display: inline-flex;
    align-items: center;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
  }
  .inv-header-actions button:hover {
    background: rgba(255, 255, 255, 0.38) !important;
  }
  .inv-header-actions button.btn-delete-inventory {
    background: rgba(239, 68, 68, 0.32) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    color: #ffffff !important;
  }
  .inv-header-actions button.btn-delete-inventory:hover {
    background: rgba(239, 68, 68, 0.5) !important;
  }

  /* Body Cells (Opening, Current, Avg Rate, Total Value, Lots) */
  #inv-panel-inventory tr td:not(:first-child):not(.table-cell-actions) {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    padding: 0.55rem 0.875rem !important;
    font-size: 13px !important;
    border-bottom: 1px solid #f0f2f7 !important;
    gap: 0.15rem !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
  }

  #inv-panel-inventory tr td:not(:first-child)::before {
    font-size: 9.5px !important;
    font-weight: 700 !important;
    color: #9ca3af !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    line-height: 1.4 !important;
    width: auto !important;
    flex: none !important;
    padding: 0 !important;
  }

  /* Row 1: Opening Stock (Left) & Current Stock (Right) */
  #inv-panel-inventory tr td:nth-child(2) {
    grid-column: 1 !important;
    border-right: 1px solid #f0f2f7 !important;
    color: #374151 !important;
    font-weight: 600 !important;
  }
  #inv-panel-inventory tr td:nth-child(2)::before {
    content: "OPENING STOCK" !important;
  }

  #inv-panel-inventory tr td:nth-child(3) {
    grid-column: 2 !important;
    color: #1f2937 !important;
    font-weight: 700 !important;
  }
  #inv-panel-inventory tr td:nth-child(3)::before {
    content: "CURRENT STOCK" !important;
  }

  /* Row 2: Avg Rate (Left) & Total Value (Right) */
  #inv-panel-inventory tr td:nth-child(4) {
    grid-column: 1 !important;
    border-right: 1px solid #f0f2f7 !important;
    color: #374151 !important;
    font-weight: 600 !important;
  }
  #inv-panel-inventory tr td:nth-child(4)::before {
    content: "AVG RATE" !important;
  }

  #inv-panel-inventory tr td:nth-child(5) {
    grid-column: 2 !important;
    color: #6366f1 !important; /* Bold indigo, matching BOM cost/unit */
    font-weight: 700 !important;
    font-size: 13.5px !important;
  }
  #inv-panel-inventory tr td:nth-child(5)::before {
    content: "TOTAL VALUE" !important;
  }

  /* Row 3: Lots (Full width spanning across both columns) */
  #inv-panel-inventory tr td:nth-child(6) {
    grid-column: 1 / -1 !important;
    font-size: 12px !important;
    color: #4b5563 !important;
    background: #fafafa !important;
    border-bottom: none !important;
  }
  #inv-panel-inventory tr td:nth-child(6)::before {
    content: "LOTS (QTY@RATE)" !important;
  }

  /* Hide Desktop Actions column on mobile */
  #inv-panel-inventory tr td:nth-child(7),
  #inv-panel-inventory tr td.table-cell-actions {
    display: none !important;
  }

  /* ===== Inventory Movement History on Mobile ===== */
  #inv-panel-history thead {
    display: none;
  }
  #inv-panel-history tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.875rem;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  }
  #inv-panel-history td {
    display: flex;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: center;
    gap: 0.5rem;
  }
  #inv-panel-history td:last-child {
    border-bottom: 0;
  }
  #inv-panel-history td::before {
    font-weight: 600;
    color: #6b7280;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  #inv-panel-history td:nth-child(1)::before { content: "Date"; }
  #inv-panel-history td:nth-child(2)::before { content: "Material"; }
  #inv-panel-history td:nth-child(3)::before { content: "Type"; }
  #inv-panel-history td:nth-child(4)::before { content: "Quantity"; }
  #inv-panel-history td:nth-child(5)::before { content: "Reason"; }
  #inv-panel-history td:nth-child(6)::before { content: "Source"; }

  /* ===== Inventory Sub-tabs — mobile ===== */

  /* Sub-tab nav: stack pills full-width */
  #inventory .overflow-x-auto {
    width: 100% !important;
  }

  #inventory .overflow-x-auto .flex.gap-1 {
    width: 100% !important;
    box-sizing: border-box;
  }

  #inventory .inv-sub-tab {
    flex: 1 1 0;
    padding: 0.55rem 0.35rem !important;
    font-size: 10.5px !important;
    text-align: center;
  }

  /* Hide text label on very small screens, keep icon */
  #inventory .inv-sub-tab span {
    flex-direction: column;
    gap: 2px;
    font-size: 10px;
    line-height: 1.2;
  }

  /* Action button bar adjustments for inventory sub-tabs */
  #inv-main-actions,
  #inv-bom-actions,
  #inv-reselling-items-actions {
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    width: 100% !important;
    overflow-x: auto !important;
  }

  #inv-main-actions > button:not(#inventory-search-toggle-btn) {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.55rem 0.6rem !important;
    font-size: 12px;
    text-align: center;
  }

  #inv-bom-actions > button:not(#bom-search-toggle-btn):not(.bom-import-btn),
  #inv-reselling-items-actions > button:not(#reselling-items-search-toggle-btn) {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  /* Inventory adjustments export button — visible on mobile */

  #inv-history-actions {
    flex-wrap: wrap;
    gap: 0.4rem;
    width: 100%;
  }

  /* ===== Inventory Adjustment History table — mobile card layout ===== */

  /* Strip outer card box */
  #inv-panel-history > div:first-of-type {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip pagination bar */
  #inv-adj-history-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  /* Make table full-width, no min-width */
  #inv-panel-history table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  /* Hide table header on mobile */
  #inv-panel-history thead {
    display: none;
  }

  /* Each row becomes a card */
  #inv-panel-history tbody tr {
    display: block;
    margin-bottom: 0.875rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }

  /* Each cell is a label-value row */
  #inv-panel-history td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.875rem;
    font-size: 13px;
    border-bottom: 1px solid #f0f3f8;
    gap: 0.75rem;
  }

  #inv-panel-history td:last-child {
    border-bottom: 0;
  }

  /* Label pseudo-element */
  #inv-panel-history td::before {
    font-weight: 600;
    color: #374151;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 38%;
    padding-right: 0.5rem;
    white-space: nowrap;
  }

  /* Value side */
  #inv-panel-history td > * {
    flex: 1;
    text-align: right;
  }

  /* Col labels */
  #inv-panel-history td:nth-child(1)::before { content: "Date"; }
  #inv-panel-history td:nth-child(2)::before { content: "Material"; }
  #inv-panel-history td:nth-child(3)::before { content: "Type"; }
  #inv-panel-history td:nth-child(4)::before { content: "Quantity"; }
  #inv-panel-history td:nth-child(5)::before { content: "Reason"; }

  /* Reason cell — wrap text instead of truncating */
  #inv-panel-history td:nth-child(5) {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  #inv-panel-history td:nth-child(5) > * {
    text-align: right;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  /* Date cell — highlight with accent colour */
  #inv-panel-history td:nth-child(1) {
    background: linear-gradient(to right, #f5f3ff, #faf5ff);
    border-bottom-color: #ede9fe;
  }

  #inv-panel-history td:nth-child(1)::before {
    color: #7c3aed;
  }

  /* Empty-state cell */
  #inv-panel-history td[colspan="5"] {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    border: none;
  }

  #inv-panel-history td[colspan="5"]::before {
    display: none;
  }

  /* ===== BOM (Products) section — mobile card layout ===== */
  #bom-search-toggle-btn {
    order: 1 !important;
    flex: 0 0 auto !important;
  }

  #inv-bom-actions .bom-export-btn {
    order: 2 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #inv-bom-actions > button[onclick*="showBomModal"] {
    order: 3 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  /* Products BOM import hidden on mobile; export remains visible */
  #inv-bom-actions > button.bom-import-btn {
    display: none !important;
  }

  /* Strip the outer table-wrapper box on mobile */
  #inv-panel-bom > div:first-of-type {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip the pagination bar outer box */
  #bom-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  #inv-bom-actions #bom-search {
    max-width: 100%;
  }

  /* Only action buttons in the header area (not in table rows) */
  #inv-bom-actions button:not(#bom-search-toggle-btn):not(.bom-import-btn):not(.bom-export-btn) {
    width: auto;
  }

  /* BOM table — full card-based redesign */
  #inv-panel-bom table,
  #inv-panel-bom #bom-table-body {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate;
    border-spacing: 0 0;
  }

  /* BOM table container — allow card shadows to show */
  #inv-panel-bom .overflow-x-auto {
    overflow-x: auto;
    max-width: 100%;
    padding: 0.25rem;
  }

  #inv-panel-bom thead {
    display: none;
  }

  /* ===== Product header row — FLEX so both tds (name + actions) show side by side ===== */
  #inv-panel-bom tr.bg-slate-50 {
    display: flex !important;            /* MUST be flex, not block, so actions td shows */
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100% !important;
    box-sizing: border-box !important;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%) !important;
    border-radius: 0.875rem 0.875rem 0 0 !important;
    overflow: hidden;
    margin-top: 1rem;
    margin-bottom: 0;
    border: none !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  }

  /* Product name cell (colspan=5) — takes all available space */
  #inv-panel-bom tr.bg-slate-50 td:first-child {
    flex: 1 1 auto;
    min-width: 0;
    flex-shrink: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #ffffff !important;
    line-height: 1.4;
    border: none !important;
    white-space: normal !important;
    word-break: break-word;
  }

  /* BOM Product Card Header - Ensure full-width container on mobile */
  #inv-panel-bom tr.bg-slate-50 td:first-child > div {
    width: 100%;
  }

  /* BOM Product Title on mobile purple header */
  #inv-panel-bom tr.bg-slate-50 .bom-product-title,
  #inv-panel-bom tr.bg-slate-50 td:first-child .text-gray-900 {
    color: #ffffff !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  }

  /* BOM Product Meta (Total Cost & Retail container) */
  #inv-panel-bom tr.bg-slate-50 .bom-product-meta,
  #inv-panel-bom tr.bg-slate-50 td:first-child .text-gray-500 {
    color: rgba(255, 255, 255, 0.92) !important;
    font-size: 0.8rem !important;
    margin-top: 0.25rem !important;
  }

  /* Total Cost value */
  #inv-panel-bom tr.bg-slate-50 .bom-total-cost,
  #inv-panel-bom tr.bg-slate-50 td:first-child .text-gray-700 {
    color: #ffffff !important;
    font-weight: 700 !important;
    background: rgba(255, 255, 255, 0.16);
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
  }

  /* Retail Price value - Bright warm yellow for maximum readability on purple background */
  #inv-panel-bom tr.bg-slate-50 .bom-retail-price,
  #inv-panel-bom tr.bg-slate-50 td:first-child .text-indigo-600,
  #inv-panel-bom tr.bg-slate-50 td:first-child .text-indigo-700 {
    color: #fef08a !important; /* Soft bright yellow / gold */
    font-weight: 700 !important;
    background: rgba(0, 0, 0, 0.22);
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
  }

  /* Icon placeholder if product has no image on mobile purple card */
  #inv-panel-bom tr.bg-slate-50 td:first-child .bg-indigo-50 {
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.4) !important;
    color: #ffffff !important;
  }
  #inv-panel-bom tr.bg-slate-50 td:first-child .bg-indigo-50 i,
  #inv-panel-bom tr.bg-slate-50 td:first-child .bg-indigo-50 svg {
    color: #ffffff !important;
  }

  /* Actions cell in product header — shrinks to fit Edit/Delete buttons */
  #inv-panel-bom tr.bg-slate-50 td:last-child {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 0.75rem;
    border: none !important;
  }

  /* Edit / Delete buttons — frosted white pills on purple */
  #inv-panel-bom tr.bg-slate-50 td:last-child button {
    width: auto !important;
    min-height: unset !important;
    background: rgba(255,255,255,0.22) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255,255,255,0.45) !important;
    border-radius: 0.5rem;
    padding: 0.35rem 0.6rem !important;
    font-size: 11.5px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
    white-space: nowrap;
  }

  #inv-panel-bom tr.bg-slate-50 td:last-child button:hover {
    background: rgba(255,255,255,0.38) !important;
  }

  /* Hide button label text — keep icon only to save space */
  #inv-panel-bom tr.bg-slate-50 td:last-child button span {
    display: none;
  }

  /* ===== Material rows — 2-column grid ===== */
  #inv-panel-bom tr.bg-white {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-bottom: 0;
    margin-top: 0;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0;
    overflow: hidden;
    background: #ffffff;
    box-shadow: none;
  }

  /* Last material row of each group — round bottom corners if no service row follows */
  #inv-panel-bom tr.bg-white:last-child,
  #inv-panel-bom tr.bg-white:not(:has(+ tr)) {
    border-radius: 0 0 0.875rem 0.875rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
    margin-bottom: 0.25rem;
  }

  /* Default cell style */
  #inv-panel-bom tr.bg-white td {
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.875rem;
    font-size: 12.5px;
    border-bottom: 1px solid #f0f2f7;
    gap: 0.1rem;
  }

  /* 1st td = empty spacer — hide */
  #inv-panel-bom tr.bg-white td:nth-child(1) {
    display: none !important;
  }

  /* ===== MATERIAL label + name on SAME LINE ===== */
  #inv-panel-bom tr.bg-white td:nth-child(2) {
    grid-column: 1 / -1;               /* full width */
    flex-direction: row;               /* label and name side by side */
    align-items: baseline;
    gap: 0.4rem;
    background: #f7f8ff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.6rem 0.875rem;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
  }

  #inv-panel-bom tr.bg-white td:nth-child(2)::before {
    content: "Material:";
    font-size: 10.5px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;                    /* label never wraps */
    line-height: 1.6;
  }

  /* ===== HIDE Rate column (td:nth-child(4)) ===== */
  #inv-panel-bom tr.bg-white td:nth-child(4) {
    display: none !important;
  }

  /* ===== Qty/Unit — left column ===== */
  #inv-panel-bom tr.bg-white td:nth-child(3) {
    border-right: 1px solid #e9edf5;
    color: #374151;
    font-weight: 500;
  }

  #inv-panel-bom tr.bg-white td:nth-child(3)::before {
    content: "QTY / UNIT";
    font-size: 9.5px;
    font-weight: 700;
    color: #9ca3af;
    letter-spacing: 0.05em;
  }

  /* ===== Cost/Unit — right column (same row as Qty) ===== */
  #inv-panel-bom tr.bg-white td:nth-child(5) {
    color: #6366f1;
    font-weight: 700;
    font-size: 13px;
  }

  #inv-panel-bom tr.bg-white td:nth-child(5)::before {
    content: "COST / UNIT";
    font-size: 9.5px;
    font-weight: 700;
    color: #9ca3af;
    letter-spacing: 0.05em;
  }

  /* Last cell in material row (empty actions spacer) — hide */
  #inv-panel-bom tr.bg-white td:nth-child(6) {
    display: none !important;
  }

  /* ===== Outsourced service rows — 2-column card grid ===== */
  #inv-panel-bom tr[class*="bg-purple-50"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-bottom: 0;
    margin-top: 0;
    border: 1px solid #e9d5ff !important;
    border-top: none !important;
    border-radius: 0;
    overflow: hidden;
    background: #faf5ff !important;
    box-shadow: none;
  }

  #inv-panel-bom tr[class*="bg-purple-50"]:last-child,
  #inv-panel-bom tr[class*="bg-purple-50"]:not(:has(+ tr)) {
    border-radius: 0 0 0.875rem 0.875rem;
    box-shadow: 0 4px 12px rgba(147, 51, 234, 0.08);
    margin-bottom: 0.25rem;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td {
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.875rem;
    font-size: 12.5px;
    border-bottom: 1px solid #f3e8ff;
    gap: 0.1rem;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(1) {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    background: #f3e8ff;
    border-bottom: 1px solid #e9d5ff;
    padding: 0.4rem 0.875rem;
    font-size: 11px;
    font-weight: 700;
    color: #7e22ce !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(2) {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.6rem 0.875rem;
    font-size: 13px;
    font-weight: 600;
    color: #581c87;
    border-bottom: 1px solid #f3e8ff;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(2)::before {
    content: "SERVICE:";
    font-size: 10.5px;
    font-weight: 700;
    color: #a855f7;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(4) {
    display: none !important;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(3) {
    border-right: 1px solid #f3e8ff;
    color: #4c1d95;
    font-weight: 500;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(3)::before {
    content: "QTY / UNIT";
    font-size: 9.5px;
    font-weight: 700;
    color: #a855f7;
    letter-spacing: 0.05em;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(5) {
    color: #7e22ce;
    font-weight: 700;
    font-size: 13px;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(5)::before {
    content: "COST / UNIT";
    font-size: 9.5px;
    font-weight: 700;
    color: #a855f7;
    letter-spacing: 0.05em;
  }

  #inv-panel-bom tr[class*="bg-purple-50"] td:nth-child(6) {
    display: none !important;
  }

  /* ===== Sales section — mobile card layout ===== */

  /* Header row: stack title + buttons vertically */
  #sale-sales > div:first-of-type {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem !important;
  }

  #sale-sales > div:first-of-type > div:first-child {
    width: 100%;
  }

  /* Action buttons row on mobile */
  #sale-sales > div:first-of-type > div.flex {
    flex-wrap: nowrap !important;
    gap: 0.4rem !important;
    width: 100% !important;
  }

  #sales-search-toggle-btn,
  #sales-filter-dropdown-container,
  #sales-combined-bill-btn,
  #sales-export-btn {
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    padding: 0 !important;
    border-radius: 9999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #sales-filter-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 9999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #sale-sales > div:first-of-type > div.flex > button[onclick*="showSaleModal"],
  #sales-add-sale-btn {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    height: 40px !important;
    max-height: 40px !important;
    padding: 0 0.85rem !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 9999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    white-space: nowrap !important;
    gap: 0.35rem !important;
  }

  /* Sales Filter Popover on Mobile: Clean Centered Floating Modal */
  #sales-filter-dropdown {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    right: auto !important;
    margin: 0 !important;
    width: min(calc(100vw - 2rem), 330px) !important;
    max-width: 90vw !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3) !important;
    border-radius: 1.25rem !important;
    z-index: 9999 !important;
    background: #ffffff !important;
    padding: 1.25rem !important;
  }

  /* Sales export button — visible on mobile */

  #sale-sales #sales-search {
    max-width: 100%;
  }

  /* Strip the outer table-wrapper box on mobile so cards go full-width */
  #sale-sales > div:nth-of-type(2) {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  #sale-sales table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #sale-sales thead {
    display: none;
  }

  #sale-sales tbody {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
  }

  #sale-sales tr {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-auto-flow: dense;
    margin-bottom: 0;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }

  #sale-sales td {
    display: flex;
    flex-direction: column;
    padding: 0.625rem 0.875rem;
    font-size: 12px;
    border-bottom: 1px solid #f3f4f6;
    gap: 0.15rem;
  }

  #sale-sales td:last-child {
    border-bottom: 0;
  }

  #sale-sales td::before {
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
  }

  /* --- Row 1: Customer (Left) & Date (Right) in single line --- */
  #sale-sales td:nth-child(2) {
    grid-column: 1 / 3;
    order: 1;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    padding: 0.625rem 0.5rem 0.625rem 0.875rem;
    border-bottom: none;
    border-right: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #sale-sales td:nth-child(2)::before {
    content: "Customer";
    color: rgba(255, 255, 255, 0.75);
  }

  #sale-sales td:nth-child(1) {
    grid-column: 3 / 4;
    order: 2;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 11.5px;
    padding: 0.625rem 0.625rem 0.625rem 0.25rem;
    text-align: right;
    align-items: flex-end;
    border-bottom: none;
    white-space: nowrap !important;
  }

  #sale-sales td:nth-child(1)::before {
    content: "Date";
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap !important;
  }

  /* --- Product (full width row) --- */
  #sale-sales td:nth-child(3) {
    grid-column: 1 / -1;
    order: 3;
    color: #4b5563;
    font-size: 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 0.45rem 0.875rem;
  }

  #sale-sales td:nth-child(3)::before {
    content: "Product";
  }

  /* --- Row 2: Amount, Received, Balance in single line --- */
  #sale-sales td:nth-child(4)::before { content: "Amount"; font-size: 9.5px; white-space: nowrap !important; }
  #sale-sales td:nth-child(5)::before { content: "Received"; font-size: 9.5px; white-space: nowrap !important; }
  #sale-sales td:nth-child(6)::before { content: "Balance"; font-size: 9.5px; white-space: nowrap !important; }

  #sale-sales td:nth-child(4) {
    grid-column: 1 / 2;
    order: 4;
    color: #1f2937;
    font-weight: 700;
    font-size: 11px;
    padding: 0.45rem 0.35rem;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    align-items: center;
  }

  #sale-sales td:nth-child(5) {
    grid-column: 2 / 3;
    order: 5;
    color: #16a34a;
    font-weight: 600;
    font-size: 11px;
    padding: 0.45rem 0.35rem;
    border-right: 1px solid #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    align-items: center;
  }

  #sale-sales td:nth-child(6) {
    grid-column: 3 / 4;
    order: 6;
    color: #dc2626;
    font-weight: 600;
    font-size: 11px;
    padding: 0.45rem 0.35rem;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    align-items: center;
  }

  /* --- Row 3: Order Status (left) + Tracking ID (right) --- */
  #sale-sales td:nth-child(8) {
    grid-column: 1 / 2;
    order: 7;
    background: #f9fafb;
    border-bottom: 0;
    border-top: 1px solid #f3f4f6;
    padding: 0.45rem 0.75rem;
    justify-content: flex-start;
    align-items: flex-start;
  }

  #sale-sales td:nth-child(8)::before {
    content: "Order Status";
  }

  #sale-sales td:nth-child(8) select {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-size: 12px !important;
    padding: 0.375rem 0.5rem !important;
    border-radius: 0.5rem !important;
    box-sizing: border-box !important;
  }

  /* --- Tracking ID on same line as Order Status --- */
  #sale-sales td:nth-child(7) {
    grid-column: 2 / -1;
    order: 8;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    border-bottom: 0;
    padding: 0.45rem 0.75rem;
    align-items: flex-start;
  }

  #sale-sales td:nth-child(7)::before {
    content: "Tracking ID";
  }

  #sale-sales td:nth-child(7) input {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-size: 12px !important;
    padding: 0.375rem 0.625rem !important;
    border-radius: 0.5rem !important;
    border: 1px solid #d1d5db !important;
    background: #ffffff !important;
    color: #1f2937 !important;
    text-align: left !important;
    box-sizing: border-box !important;
  }

  /* --- Row 4 (bottom): Payment (left) + Actions (right) --- */
  #sale-sales td:nth-child(9) {
    grid-column: 1 / 2;
    order: 9;
    background: #f9fafb;
    border-bottom: 0;
    border-top: 1px solid #f3f4f6;
    padding: 0.5rem 0.75rem;
    justify-content: flex-start;
    align-items: flex-start;
  }

  #sale-sales td:nth-child(9)::before {
    content: "Payment";
  }

  #sale-sales td:nth-child(10) {
    grid-column: 2 / -1;
    order: 10;
    background: #f9fafb;
    border-bottom: 0;
    border-top: 1px solid #f3f4f6;
    padding: 0.5rem 0.75rem;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
  }

  #sale-sales td:nth-child(10)::before {
    display: none;
  }

  #sale-sales td:nth-child(10) button {
    width: auto !important;
    min-height: unset;
    padding: 0.375rem 0.625rem !important;
    font-size: 12px;
    border-radius: 0.5rem;
  }


  /* Strip the pagination bar's outer box on mobile */
  #sales-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  /* Sales modal form fields on mobile */
  #sale-modal .modal-content .grid,
  #sale-modal .modal-content .grid.grid-cols-1\.md\:grid-cols-2\.gap-4 {
    grid-template-columns: 1fr !important;
  }

  #sale-modal .modal-content .form-input,
  #sale-modal .modal-content .form-select {
    width: 100% !important;
  }

  /* Balances section mobile layout */
  #balances h2 {
    font-size: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
  }

  /* Hide Account Balances table on mobile */
  #balances > h2:first-of-type {
    display: none;
  }

  #balances > h2:first-of-type + div {
    display: none;
  }

  #balances table,
  #sale-receivables table,
  #purchase-payables table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #balances thead,
  #sale-receivables thead,
  #purchase-payables thead {
    display: none;
  }

  #balances tr,
  #sale-receivables tr,
  #purchase-payables tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
  }

  #balances td,
  #sale-receivables td,
  #purchase-payables td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #balances td:last-child,
  #sale-receivables td:last-child,
  #purchase-payables td:last-child {
    border-bottom: 0;
  }

  #balances td::before,
  #sale-receivables td::before,
  #purchase-payables td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    width: 40%;
    flex: 0 0 40%;
    padding-right: 0.75rem;
    white-space: normal;
  }

  #balances td > *,
  #sale-receivables td > *,
  #purchase-payables td > * {
    flex: 1;
  }

  /* Balances table specific labels */
  #balances-table-body td:nth-child(1)::before { content: "Account"; }
  #balances-table-body td:nth-child(2)::before { content: "Balance"; }

  /* Receivables table specific labels */
  #sale-receivables-table-body td:nth-child(1)::before { content: "Customer"; }
  #sale-receivables-table-body td:nth-child(2)::before { content: "Outstanding"; }
  #sale-receivables-table-body td:nth-child(3)::before { content: "Action"; }

  /* Payables table specific labels */
  #payables-table-body td:nth-child(1)::before { content: "Supplier"; }
  #payables-table-body td:nth-child(2)::before { content: "Outstanding"; }
  #payables-table-body td:nth-child(3)::before { content: "Action"; }

  /* Action buttons on mobile - show only icons */
  #balances-table-body button,
  #sale-receivables-table-body button,
  #payables-table-body button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: #f3f4f6;
    transition: all 0.2s ease;
    min-width: 2.5rem;
  }

  #balances-table-body button:hover,
  #sale-receivables-table-body button:hover,
  #payables-table-body button:hover {
    background: #e5e7eb;
  }

  /* Hide button text on mobile */
  #balances-table-body button span,
  #sale-receivables-table-body button span,
  #payables-table-body button span {
    display: none;
  }

  /* Show icons for buttons */
  #balances-table-body button i,
  #sale-receivables-table-body button i,
  #payables-table-body button i {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Ensure action columns take appropriate space */
  #sale-receivables-table-body td:nth-child(3),
  #payables-table-body td:nth-child(3) {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
  }

  /* ===== Accounts section — strip outer boxes ===== */

  /* Accounts action buttons row */
  #accounts > div.flex.justify-between.items-center {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 1rem !important;
  }

  #accounts > div.flex.justify-between.items-center > div.flex.items-center.gap-3 {
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  #accounts > div.flex.justify-between.items-center > div.flex.items-center.gap-3 > button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.6rem 0.75rem !important;
    font-size: 12px;
    text-align: center;
  }

  /* Strip accounts table wrapper box */
  #accounts > div.bg-white\/80 {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip accounts pagination box */
  #accounts-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  /* Strip transitions history filter panel box */
  #accounts > div.mt-8 > div.bg-white\/80 {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  /* Strip transitions history table box */
  #accounts > div.mt-8 > div.bg-white\/80.rounded-2xl.p-6.shadow-xl.border.border-white\/20.overflow-x-auto {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* ===== Sale Receivables — strip outer box ===== */
  #sale-receivables > div.bg-white\/80 {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* ===== Purchase Payables — strip outer box ===== */
  #purchase-payables > div.bg-white\/80 {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* ===== Reselling Items section — mobile card layout ===== */
  #inv-panel-reselling-items {
    overflow: visible !important;
  }

  /* Strip the outer table-wrapper box */
  #inv-panel-reselling-items > div.bg-white\/80 {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Table reset */
  #inv-panel-reselling-items table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  /* Hide table header */
  #inv-panel-reselling-items thead {
    display: none;
  }

  /* Stack rows vertically */
  #inv-panel-reselling-items tbody {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
  }

  /* Each row = a card */
  #inv-panel-reselling-items tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }

  /* Each cell: label on top, value below */
  #inv-panel-reselling-items td {
    display: flex;
    flex-direction: column;
    padding: 0.625rem 0.875rem;
    font-size: 12px;
    border-bottom: 1px solid #f3f4f6;
    gap: 0.15rem;
  }

  #inv-panel-reselling-items td:last-child {
    border-bottom: 0;
  }

  /* Pseudo-label above each value */
  #inv-panel-reselling-items td::before {
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.1rem;
  }

  /* Reselling Items Table Layout */
  #reselling-table-body td:nth-child(1) {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    padding: 0.75rem 1rem;
    border-bottom: none;
  }

  #reselling-table-body td:nth-child(1)::before {
    content: "Item Name";
    color: rgba(255,255,255,0.75);
  }

  #reselling-table-body td:nth-child(2) {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
  }
  #reselling-table-body td:nth-child(2)::before { content: "Supplier"; }

  #reselling-table-body td:nth-child(3)::before { content: "Purchase Rate"; }
  #reselling-table-body td:nth-child(3) {
    color: #374151;
    font-weight: 600;
    font-size: 13px;
    border-right: 1px solid #f3f4f6;
  }

  #reselling-table-body td:nth-child(4)::before { content: "MOQ"; }
  #reselling-table-body td:nth-child(4) {
    color: #374151;
    font-weight: 500;
  }

  #reselling-table-body td:nth-child(5) {
    grid-column: 1 / -1;
    border-bottom: 1px solid #e5e7eb;
    color: #16a34a;
    font-weight: 700;
    font-size: 13px;
  }
  #reselling-table-body td:nth-child(5)::before { content: "Sale Rate"; }

  #reselling-table-body td:nth-child(6) {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 0;
    padding: 0.625rem 0.875rem;
    justify-content: flex-start;
  }

  #reselling-table-body td:nth-child(6)::before {
    display: none;
  }

  #reselling-table-body td:nth-child(6) button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.5rem;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.15s ease;
  }

  #reselling-table-body td:nth-child(6) .flex {
    flex-direction: row;
    gap: 0.5rem;
  }

  /* Reselling Orders Table Layout */
  #reselling-orders-table-body td:nth-child(1) {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 13px;
    padding: 0.75rem 1rem;
    border-bottom: none;
  }

  #reselling-orders-table-body td:nth-child(1)::before {
    content: "Date";
    color: rgba(255,255,255,0.75);
  }

  #reselling-orders-table-body td:nth-child(2) {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
  }
  #reselling-orders-table-body td:nth-child(2)::before { content: "Customer"; }

  #reselling-orders-table-body td:nth-child(3) {
    grid-column: 1 / -1;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
  }
  #reselling-orders-table-body td:nth-child(3)::before { content: "Item"; }

  #reselling-orders-table-body td:nth-child(4)::before { content: "Qty"; }
  #reselling-orders-table-body td:nth-child(4) {
    border-right: 1px solid #f3f4f6;
    color: #374151;
    font-weight: 500;
  }

  #reselling-orders-table-body td:nth-child(5)::before { content: "Sale Rate"; }
  #reselling-orders-table-body td:nth-child(5) {
    color: #374151;
    font-weight: 500;
  }

  #reselling-orders-table-body td:nth-child(6)::before { content: "Amount"; }
  #reselling-orders-table-body td:nth-child(6) {
    border-right: 1px solid #f3f4f6;
    color: #374151;
    font-weight: 700;
    font-size: 13px;
  }

  #reselling-orders-table-body td:nth-child(7)::before { content: "Received"; }
  #reselling-orders-table-body td:nth-child(7) {
    color: #16a34a;
    font-weight: 600;
  }

  #reselling-orders-table-body td:nth-child(8)::before { content: "Balance"; }
  #reselling-orders-table-body td:nth-child(8) {
    border-right: 1px solid #f3f4f6;
    color: #dc2626;
    font-weight: 600;
  }

  #reselling-orders-table-body td:nth-child(9)::before { content: "Status"; }

  #reselling-orders-table-body td:nth-child(10) {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 0;
    padding: 0.625rem 0.875rem;
    justify-content: flex-start;
  }

  #reselling-orders-table-body td:nth-child(10)::before {
    display: none;
  }

  #reselling-orders-table-body td:nth-child(10) button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.45rem 0.85rem;
    border-radius: 0.5rem;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.15s ease;
  }

  #reselling-orders-table-body td:nth-child(10) .flex {
    flex-direction: row;
    gap: 0.5rem;
  }

  /* Empty state full-width */
  #inv-panel-reselling-items tr td[colspan="5"],
  #inv-panel-reselling-items tr td[colspan="6"],
  #inv-panel-reselling-items tr td[colspan="10"] {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem 1rem;
    background: #ffffff;
    color: #6b7280;
  }

  /* Expenses section mobile layout */
  #expenses > div:first-of-type {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem !important;
  }

  #expenses > div:first-of-type > div:first-child {
    width: 100%;
  }

  #expenses > div:first-of-type > div.flex.items-center.gap-3 {
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    width: 100% !important;
  }

  #expenses-search-toggle-btn {
    order: 1 !important;
    flex: 0 0 auto !important;
  }

  #expenses > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="handleExpensesReportExports"],
  #expenses > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="Export"] {
    order: 2 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #expenses > div:first-of-type > div.flex.items-center.gap-3 > button[onclick*="showExpenseModal"] {
    order: 3 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    margin-left: 0 !important;
    white-space: nowrap !important;
  }

  #expenses #expenses-search {
    max-width: 100%;
  }

  /* Strip the outer table-wrapper box on mobile */
  #expenses > div:nth-of-type(2) {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip the pagination bar outer box */
  #expenses-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  #expenses table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #expenses thead {
    display: none;
  }

  #expenses tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
  }

  #expenses td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #expenses td:last-child {
    border-bottom: 0;
  }

  #expenses td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    width: 40%;
    flex: 0 0 40%;
    padding-right: 0.75rem;
    white-space: normal;
  }

  #expenses td > * {
    flex: 1;
  }

  #expenses td:nth-child(1)::before { content: "Date"; }
  #expenses td:nth-child(2)::before { content: "Category"; }
  #expenses td:nth-child(3)::before { content: "Amount"; }
  #expenses td:nth-child(4)::before { content: "Account"; }
  #expenses td:nth-child(5)::before { content: "Description"; }
  #expenses td:nth-child(6)::before { content: "Bill"; }
  #expenses td:nth-child(7)::before { content: "Actions"; }

  #expenses td:nth-child(6),
  #expenses td:nth-child(7) {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  #expenses td:nth-child(7) {
    flex-direction: column;
    align-items: flex-start;
  }

  #expenses td:nth-child(7) > * {
    width: 100%;
  }

  #expenses td:nth-child(7) .flex {
    width: 100%;
    gap: 0.5rem;
  }

  #expenses td:nth-child(7) button {
    width: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #expenses td:nth-child(7) button span {
    display: none;
  }

  #expenses td:nth-child(7) button i {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
  }

  #expenses .bg-gradient-to-r.from-green-500.to-emerald-600 {
    display: none !important;
  }

  /* Assets section mobile layout */
  #assets > div:nth-of-type(2) {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem !important;
  }

  #assets > div:nth-of-type(2) > div:last-child {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    width: 100% !important;
  }

  #assets > div:nth-of-type(2) > div:last-child > button[onclick*="handleAssetsReportExports"],
  #assets > div:nth-of-type(2) > div:last-child > button[onclick*="Export"] {
    order: 1 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  #assets > div:nth-of-type(2) > div:last-child > button[onclick*="showAssetModal"] {
    order: 2 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 0.55rem 0.4rem !important;
    font-size: 12px !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  /* Assets export button — visible on mobile */

  /* Strip the outer table-wrapper box on mobile */
  #assets > div:nth-of-type(3) {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip the pagination bar outer box */
  #assets-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  #assets table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #assets thead {
    display: none;
  }

  #assets tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
  }

  #assets td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #assets td:last-child {
    border-bottom: 0;
  }

  #assets td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    width: 40%;
    flex: 0 0 40%;
    padding-right: 0.75rem;
    white-space: normal;
  }

  #assets td > * {
    flex: 1;
  }

  #assets td:nth-child(1)::before { content: "Asset Name"; }
  #assets td:nth-child(2)::before { content: "Purchase Price"; }
  #assets td:nth-child(3)::before { content: "Depreciation"; }
  #assets td:nth-child(4)::before { content: "Current Value"; }
  #assets td:nth-child(5)::before { content: "Status"; }

  #assets td:nth-child(6) {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 0;
    padding: 0.625rem 0.875rem;
  }

  #assets td:nth-child(6)::before {
    display: none;
  }

  #assets td:nth-child(6) button {
    width: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #assets td:nth-child(6) button span {
    display: none;
  }

  #assets td:nth-child(6) button i {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
  }

  #assets .bg-gradient-to-r.from-green-500.to-emerald-600 {
    display: none !important;
  }

  /* Users section mobile layout */
  #settings-users > div:nth-of-type(2) {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 1rem !important;
  }

  #settings-users > div:nth-of-type(2) > button {
    width: 100%;
    padding: 0.6rem 0.75rem !important;
    font-size: 13px;
  }

  /* Strip the outer table-wrapper box on mobile */
  #settings-users > div:nth-of-type(3) {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip the pagination bar outer box */
  #users-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  #users table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #users thead {
    display: none;
  }

  #users tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
  }

  #users td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #users td:last-child {
    border-bottom: 0;
  }

  #users td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    width: 40%;
    flex: 0 0 40%;
    padding-right: 0.75rem;
    white-space: normal;
  }

  #users td > * {
    flex: 1;
  }

  #users td:nth-child(1)::before { content: "Username"; }
  #users td:nth-child(2)::before { content: "Name"; }
  #users td:nth-child(3)::before { content: "Role"; }
  #users td:nth-child(4)::before { content: "Actions"; }

  #users td:nth-child(4) {
    flex-direction: column;
    align-items: flex-start;
  }

  #users td:nth-child(4) > * {
    width: 100%;
  }

  #users td:nth-child(4) .flex {
    width: 100%;
    gap: 0.5rem;
  }

  #users td:nth-child(4) button {
    width: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #users td:nth-child(4) button span {
    display: none;
  }

  #users td:nth-child(4) button i {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Roles section mobile layout */
  #settings-roles > div:nth-of-type(2) {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 1rem !important;
  }

  #settings-roles > div:nth-of-type(2) > button {
    width: 100%;
    padding: 0.6rem 0.75rem !important;
    font-size: 13px;
  }

  /* Strip the outer table-wrapper box on mobile */
  #settings-roles > div:nth-of-type(3) {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  #roles table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #roles thead {
    display: none;
  }

  #roles tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
  }

  #roles td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #roles td:last-child {
    border-bottom: 0;
  }

  #roles td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    width: 40%;
    flex: 0 0 40%;
    padding-right: 0.75rem;
    white-space: normal;
  }

  #roles td > * {
    flex: 1;
  }

  #roles td:nth-child(1)::before { content: "Role Name"; }
  #roles td:nth-child(2)::before { content: "Permissions"; }
  #roles td:nth-child(3)::before { content: "Actions"; }

  #roles td:nth-child(2) {
    flex-direction: column;
    align-items: flex-start;
  }

  #roles td:nth-child(3) {
    flex-direction: column;
    align-items: flex-start;
  }

  #roles td:nth-child(3) > * {
    width: 100%;
  }

  #roles td:nth-child(3) .flex {
    width: 100%;
    gap: 0.5rem;
  }

  #roles td:nth-child(3) button {
    width: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #roles td:nth-child(3) button span {
    display: none;
  }

  #roles td:nth-child(3) button i {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Customer and Supplier sections mobile layout */

  /* Sale Customer header bar */
  #sale-customer-pane > div > div:first-of-type {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 0 !important;
  }

  #sale-customer-pane > div > div:first-of-type > div:first-child {
    width: 100%;
  }

  #sale-customer-pane > div > div:first-of-type > div.flex.items-center.gap-3 {
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  #sale-customer-pane > div > div:first-of-type > div.flex.items-center.gap-3 > button:not(#customer-search-toggle-btn) {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.6rem 0.75rem !important;
    font-size: 13px;
  }

  /* Strip customer table wrapper box */
  #sale-customer-pane > div > div.bg-white {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip customer pagination box */
  #customers-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  /* Purchase Suppliers header bar */
  #purchase-suppliers > div {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  #purchase-suppliers > div > div.flex.items-center.justify-between {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  #purchase-suppliers > div > div.flex.items-center.justify-between > div.flex.items-center.gap-3 {
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  #purchase-suppliers > div > div.flex.items-center.justify-between > div.flex.items-center.gap-3 > button:not(#supplier-search-toggle-btn) {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.6rem 0.75rem !important;
    font-size: 13px;
  }

  /* Strip supplier table wrapper box */
  #purchase-suppliers > div > div.overflow-x-auto {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Strip suppliers pagination box */
  #suppliers-pagination {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
    margin-top: 0.75rem !important;
  }

  #sale-customer-pane table,
  #purchase-suppliers table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
  }

  #sale-customer-pane thead,
  #purchase-suppliers thead {
    display: none;
  }

  #sale-customer-pane tr,
  #purchase-suppliers tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    overflow: hidden;
    background: #ffffff;
  }

  #sale-customer-pane td,
  #purchase-suppliers td {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0.75rem;
    font-size: 13px;
    border-bottom: 1px solid #eef2f7;
    align-items: flex-start;
    gap: 0.75rem;
  }

  #sale-customer-pane td:last-child,
  #purchase-suppliers td:last-child {
    border-bottom: 0;
  }

  #sale-customer-pane td::before,
  #purchase-suppliers td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #374151;
    width: 40%;
    flex: 0 0 40%;
    padding-right: 0.75rem;
    white-space: normal;
  }

  #sale-customer-pane td > *,
  #purchase-suppliers td > * {
    flex: 1;
  }

  #sale-customer-pane td:nth-child(1)::before, #purchase-suppliers td:nth-child(1)::before { content: "Name"; }
  #sale-customer-pane td:nth-child(2)::before, #purchase-suppliers td:nth-child(2)::before { content: "Contact"; }
  #sale-customer-pane td:nth-child(3)::before, #purchase-suppliers td:nth-child(3)::before { content: "Email"; }
  #sale-customer-pane td:nth-child(4)::before, #purchase-suppliers td:nth-child(4)::before { content: "Address"; }
  #sale-customer-pane td:nth-child(5)::before, #purchase-suppliers td:nth-child(5)::before { content: "Actions"; }

  /* Hide Email and Address columns on mobile */
  #sale-customer-pane td:nth-child(3),
  #sale-customer-pane td:nth-child(4),
  #purchase-suppliers td:nth-child(3),
  #purchase-suppliers td:nth-child(4) {
    display: none;
  }

  #sale-customer-pane td:nth-child(4),
  #purchase-suppliers td:nth-child(4) {
    flex-direction: column;
    align-items: flex-start;
  }

  #sale-customer-pane td:nth-child(5),
  #purchase-suppliers td:nth-child(5) {
    flex-direction: column;
    align-items: flex-start;
  }

  #sale-customer-pane td:nth-child(5) > *,
  #purchase-suppliers td:nth-child(5) > * {
    width: 100%;
  }

  #sale-customer-pane td:nth-child(5) .flex,
  #purchase-suppliers td:nth-child(5) .flex {
    width: 100%;
    gap: 0.5rem;
  }

  #sale-customer-pane td:nth-child(5) button,
  #purchase-suppliers td:nth-child(5) button {
    width: auto;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #sale-customer-pane td:nth-child(5) button span,
  #purchase-suppliers td:nth-child(5) button span {
    display: none;
  }

  #sale-customer-pane td:nth-child(5) button i,
  #purchase-suppliers td:nth-child(5) button i {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Stats cards */
  .grid-cols-1\.md\:grid-cols-2\.lg\:grid-cols-5 {
    grid-template-columns: 1fr;
  }
  
  /* Button adjustments */
  button {
    white-space: nowrap;
  }
  
  /* Search inputs */
  input[type="text"] {
    width: 100%;
    margin-bottom: 1rem;
  }
  
  /* Header actions */
  .flex.justify-between.items-center {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .flex.justify-between.items-center > div {
    width: 100%;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar-format {
    width: 200px;
    min-width: 200px;
  }

  /* main is flex-1 — no margin-left needed; flex handles spacing */

  .grid-cols-1\.md\:grid-cols-2\.lg\:grid-cols-5 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop adjustments */
@media (min-width: 1025px) {
  .mobile-menu-toggle {
    display: none;
  }
}

/* Utility classes for mobile */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
}

/* Touch-friendly elements */
button, .form-input, .form-select {
  min-height: 44px; /* Minimum touch target size */
}

/* Improved scrolling on mobile */
.modal-content {
  -webkit-overflow-scrolling: touch;
}

/* Search results dropdown */
.search-results {
  max-height: 200px;
  overflow-y: auto;
}

/* Bill image modal on mobile */
#bill-image-modal .modal-content {
  padding: 1rem;
}

#bill-image {
  max-width: 100%;
  height: auto;
}

/* Table cell adjustments for mobile */
@media (max-width: 768px) {
  .table-cell-actions {
    min-width: auto;
  }
  
  td, th {
    padding: 0.5rem 0.25rem;
    font-size: 12px;
  }
}

/* Form layout improvements */
@media (max-width: 768px) {
  .space-y-4 > * {
    margin-bottom: 1rem;
  }
  
  .grid.grid-cols-1\.md\:grid-cols-2\.gap-4 {
    grid-template-columns: 1fr;
  }
  
  /* ===== DASHBOARD STATS CARDS: 2 cards per line (horizontal box) on mobile ===== */
  #dashboard .grid.grid-cols-2 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
    overflow-x: visible !important;
  }

  /* Each card: small horizontal box (width > height) */
  #dashboard .grid.grid-cols-2 > div {
    flex: none !important;
    min-width: 0 !important;
    width: 100% !important;
    padding: 0.5rem 0.625rem !important;
    border-radius: 0.875rem !important;
  }

  /* 9th card (or odd last card) -> span 2 columns (full width & centered) */
  #dashboard .grid.grid-cols-2 > div:last-child:nth-child(odd) {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Inner flex: keep row direction so it's landscape */
  #dashboard .grid.grid-cols-2 > div > .flex {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.375rem !important;
    width: 100% !important;
  }

  #dashboard .grid.grid-cols-2 > div > .flex > div:first-child {
    width: auto !important;
    flex: 1 !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  #dashboard .grid.grid-cols-2 > div .text-sm.font-medium {
    font-size: 0.725rem !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Dashboard card value */
  #dashboard .grid.grid-cols-2 > div .text-3xl.font-bold {
    font-size: 1.125rem !important;
    line-height: 1.2 !important;
    margin-top: 0.15rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #dashboard .text-xs {
    font-size: 0.65rem !important;
  }

  /* Icon container — compact, right-aligned */
  #dashboard .grid.grid-cols-2 > div > .flex > div:last-child {
    padding: 0.3rem 0.35rem !important;
    border-radius: 0.5rem !important;
    width: auto !important;
    height: auto !important;
    flex-shrink: 0 !important;
  }

  #dashboard .grid.grid-cols-2 > div > .flex > div:last-child i,
  #dashboard .grid.grid-cols-2 > div > .flex > div:last-child svg {
    width: 0.85rem !important;
    height: 0.85rem !important;
    min-width: 0.85rem !important;
    min-height: 0.85rem !important;
  }

  /* Dashboard charts section — stack vertically */
  #dashboard .grid.grid-cols-1.lg\:grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Dashboard chart containers */
  #dashboard .relative.h-80,
  #dashboard #sales-chart-wrapper {
    height: 250px !important;
    min-height: 250px !important;
  }

  /* Dashboard header */
  #dashboard h1.text-3xl {
    font-size: 1.75rem !important;
  }

  #dashboard p.text-gray-600 {
    font-size: 0.875rem !important;
  }

  /* Dashboard chart filter select & buttons */
  #dashboard .flex.gap-3 button,
  #dashboard #sales-trend-filter {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
  }

  /* Dashboard chart titles */
  #dashboard h2.text-2xl {
    font-size: 1.25rem !important;
  }

  /* Dashboard mobile list item overrides */
  #dashboard #top-products-list-mobile > div {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }
}

/* Extra small mobile devices (phones < 480px) */
@media (max-width: 480px) {
  #dashboard .grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }

  #dashboard .grid.grid-cols-2 > div {
    padding: 0.45rem 0.5rem !important;
    border-radius: 0.75rem !important;
  }

  #dashboard .relative.h-80,
  #dashboard #sales-chart-wrapper {
    height: 200px !important;
    min-height: 200px !important;
  }

  #dashboard .grid.grid-cols-2 > div .text-3xl.font-bold {
    font-size: 1.05rem !important;
  }

  #dashboard h1.text-3xl {
    font-size: 1.5rem !important;
  }

  #dashboard .flex.gap-3 {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }

  #dashboard .flex.gap-3 button,
  #dashboard #sales-trend-filter {
    flex: 1 1 auto !important;
    min-width: 80px !important;
    padding: 0.4rem 0.6rem !important;
    font-size: 0.7rem !important;
  }
}

/* Login modal adjustments */
@media (max-width: 768px) {
  #login-modal .modal-content {
    margin: 2rem 1rem;
  }
}

/* Ensure proper viewport scaling */
@-ms-viewport {
  width: device-width;
}

@viewport {
  width: device-width;
}

/* Prevent text size adjustment */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Improved button spacing */
@media (max-width: 768px) {
  .flex.gap-2 {
    gap: 0.5rem;
  }
  
  .flex.gap-4 {
    gap: 1rem;
  }
}

/* Modal header adjustments */
@media (max-width: 768px) {
  .modal-content .flex.justify-between.items-center {
    flex-direction: row;
    align-items: center;
  }
}

/* Inventory adjustment modal */
@media (max-width: 768px) {
  .modal-content {
    margin: 1rem;
    padding: 1.5rem;
    width: calc(100% - 2rem);
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* Hide Full Year Monthly Report on mobile */
@media (max-width: 768px) {
  #full-year-report {
    display: none;
  }
}

/* Mobile overlay for sidebar */
.mobile-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  display: none;
}

.mobile-overlay.active {
  display: block;
}

/* Close sidebar button */
.close-sidebar {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
}

/* Responsive table improvements */
@media (max-width: 768px) {
  .responsive-table {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
  
  .responsive-table table {
    min-width: 600px;
  }
}

/* Form field spacing on mobile */
@media (max-width: 768px) {
  .form-field {
    margin-bottom: 1rem;
  }
}

/* Card adjustments for mobile */
@media (max-width: 768px) {
  .card {
    margin-bottom: 1rem;
  }
}

/* Sidebar toggle button mobile adjustments */
@media (max-width: 768px) {
  #sidebar-toggle-btn {
    display: none !important;
  }
  /* Override collapsed rules on mobile drawer */
  .sidebar-format.collapsed {
    width: 280px !important;
    min-width: 280px !important;
    padding: 1rem !important;
  }
  .sidebar-format.collapsed .sidebar-header .logo-full {
    display: block !important;
  }
  .sidebar-format.collapsed .sidebar-header .logo-collapsed {
    display: none !important;
  }
  .sidebar-format.collapsed .sidebar-nav button span {
    display: inline !important;
  }
  .sidebar-format.collapsed .sidebar-nav .nav-quick-add-btn {
    display: inline-flex !important;
  }
  .sidebar-format.collapsed .sidebar-nav button {
    justify-content: flex-start !important;
    padding: 0.9rem 1rem !important;
    width: 100% !important;
  }
  .sidebar-format.collapsed .sidebar-footer .flex.items-center.gap-2 {
    justify-content: flex-start !important;
    padding: 0.75rem !important;
  }
  .sidebar-format.collapsed .sidebar-footer .text-sm {
    display: block !important;
  }
  .sidebar-format.collapsed #logout-btn span {
    display: inline !important;
  }
  .sidebar-format.collapsed #logout-btn {
    padding: 0.75rem 1rem !important;
    justify-content: center !important;
  }
}

/* ===================================================
   Sale & Purchase View Details Modal — Mobile Styles
   =================================================== */
@media (max-width: 640px) {

  /* ── Modal container ── */
  #sale-details-modal .modal-content,
  #purchase-details-modal .modal-content {
    width: calc(100vw - 1rem) !important;
    max-width: 100% !important;
    margin: 0.5rem auto;
    padding: 1rem !important;
    border-radius: 1rem;
    max-height: 92vh;
    overflow-y: auto;
  }

  /* ── Modal header: keep title left, buttons right ── */
  #sale-details-modal .modal-content > div:first-child,
  #purchase-details-modal .modal-content > div:first-child {
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 1rem !important;
    padding-bottom: 0.75rem !important;
  }

  /* Shrink modal title on mobile */
  #sale-details-modal .modal-content h2,
  #purchase-details-modal .modal-content h2 {
    font-size: 0.9rem !important;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Shrink the lucide icon next to title */
  #sale-details-modal .modal-content h2 i,
  #purchase-details-modal .modal-content h2 i {
    width: 1rem !important;
    height: 1rem !important;
    flex-shrink: 0;
  }

  /* Make Print & WhatsApp icon buttons larger and easier to tap */
  #modal-print-btn,
  #modal-whatsapp-btn {
    width: 2.25rem !important;
    height: 2.25rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.5rem;
    background: #f3f4f6;
    flex-shrink: 0;
  }

  #modal-print-btn i,
  #modal-whatsapp-btn svg {
    width: 1.2rem !important;
    height: 1.2rem !important;
  }

  /* ── Info cards: stack to single column ── */
  #sale-details-modal .modal-content .grid,
  #purchase-details-modal .modal-content .grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* Tighten info card padding */
  #sale-details-modal .modal-content .bg-gray-50,
  #purchase-details-modal .modal-content .bg-gray-50 {
    padding: 0.625rem 0.75rem !important;
    font-size: 0.8rem;
  }

  /* ── Resell details panel ── */
  #view-sale-resell-details {
    padding: 0.625rem 0.75rem !important;
    margin-bottom: 0.75rem !important;
    font-size: 0.8rem;
  }

  /* ── Items / Materials table: horizontal scroll ── */
  #sale-details-modal .modal-content .border.rounded-xl,
  #purchase-details-modal .modal-content .border.rounded-xl {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.75rem !important;
  }

  #view-sale-items-body ~ thead th,
  #sale-details-modal .modal-content table,
  #purchase-details-modal .modal-content table {
    min-width: 380px;
    font-size: 0.75rem !important;
  }

  #sale-details-modal .modal-content thead th,
  #purchase-details-modal .modal-content thead th {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.65rem !important;
  }

  #sale-details-modal .modal-content tbody td,
  #purchase-details-modal .modal-content tbody td {
    padding: 0.5rem 0.75rem !important;
  }

  /* ── Freight/Builty panel ── */
  #view-purchase-freight-details {
    padding: 0.625rem 0.75rem !important;
    margin-bottom: 0.75rem !important;
    font-size: 0.8rem;
  }

  /* ── Totals section: full-width ── */
  #sale-details-modal .modal-content .flex.justify-end,
  #purchase-details-modal .modal-content .flex.justify-end {
    justify-content: stretch !important;
    margin-bottom: 0.75rem !important;
  }

  #sale-details-modal .modal-content .w-full,
  #purchase-details-modal .modal-content .w-full {
    width: 100% !important;
    font-size: 0.8rem;
  .responsive-table table {
    min-width: 600px;
  }
}

/* Form field spacing on mobile */
@media (max-width: 768px) {
  .form-field {
    margin-bottom: 1rem;
  }
}

/* Card adjustments for mobile */
@media (max-width: 768px) {
  .card {
    margin-bottom: 1rem;
  }
}

/* Sidebar toggle button mobile adjustments */
@media (max-width: 768px) {
  #sidebar-toggle-btn {
    display: none !important;
  }
  /* Override collapsed rules on mobile drawer */
  .sidebar-format.collapsed {
    width: 280px !important;
    min-width: 280px !important;
    padding: 1rem !important;
  }
  .sidebar-format.collapsed .sidebar-header .logo-full {
    display: block !important;
  }
  .sidebar-format.collapsed .sidebar-header .logo-collapsed {
    display: none !important;
  }
  .sidebar-format.collapsed .sidebar-nav button span {
    display: inline !important;
  }
  .sidebar-format.collapsed .sidebar-nav .nav-quick-add-btn {
    display: inline-flex !important;
  }
  .sidebar-format.collapsed .sidebar-nav button {
    justify-content: flex-start !important;
    padding: 0.9rem 1rem !important;
    width: 100% !important;
  }
  .sidebar-format.collapsed .sidebar-footer .flex.items-center.gap-2 {
    justify-content: flex-start !important;
    padding: 0.75rem !important;
  }
  .sidebar-format.collapsed .sidebar-footer .text-sm {
    display: block !important;
  }
  .sidebar-format.collapsed #logout-btn span {
    display: inline !important;
  }
  .sidebar-format.collapsed #logout-btn {
    padding: 0.75rem 1rem !important;
    justify-content: center !important;
  }
}

/* ===================================================
   Sale & Purchase View Details Modal — Mobile Styles
   =================================================== */
@media (max-width: 640px) {

  /* ── Modal container ── */
  #sale-details-modal .modal-content,
  #purchase-details-modal .modal-content {
    width: calc(100vw - 1rem) !important;
    max-width: 100% !important;
    margin: 0.5rem auto;
    padding: 1rem !important;
    border-radius: 1rem;
    max-height: 92vh;
    overflow-y: auto;
  }

  /* ── Modal header: title left (icon only), action buttons RIGHT ── */
  #sale-details-modal .modal-content > div:first-child,
  #purchase-details-modal .modal-content > div:first-child {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 1rem !important;
    padding-bottom: 0.75rem !important;
  }

  /* Hide long title TEXT on mobile — keeps icon visible */
  #sale-details-modal .modal-content h2 span,
  #purchase-details-modal .modal-content h2 span {
    display: none !important;
  }

  /* Keep the info icon as a compact title indicator */
  #sale-details-modal .modal-content h2,
  #purchase-details-modal .modal-content h2 {
    font-size: 0.9rem !important;
    flex-shrink: 0;
    display: flex;
    align-items: center;
  }

  #sale-details-modal .modal-content h2 i,
  #purchase-details-modal .modal-content h2 i {
    width: 1.25rem !important;
    height: 1.25rem !important;
    flex-shrink: 0;
  }

  /* Push Print + WhatsApp + Close group to the RIGHT corner */
  #sale-details-modal .modal-content > div:first-child > div.flex,
  #purchase-details-modal .modal-content > div:first-child > button {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  /* Make Print & WhatsApp tap targets larger and clearly visible */
  #modal-print-btn,
  #modal-whatsapp-btn {
    width: 2.5rem !important;
    height: 2.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.625rem;
    background: #f3f4f6;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
  }

  #modal-print-btn i,
  #modal-whatsapp-btn svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }

  @media (max-width: 480px) {
    #dashboard .grid.grid-cols-2 {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      gap: 0.5rem !important;
    }

    #dashboard .grid.grid-cols-2 > div {
      padding: 0.45rem 0.5rem !important;
      border-radius: 0.75rem !important;
    }

    #dashboard .grid.grid-cols-2 > div .text-sm.font-medium {
      font-size: 0.65rem !important;
    }

    #dashboard .grid.grid-cols-2 > div .text-3xl.font-bold {
      font-size: 0.85rem !important;
      margin-top: 0.1rem !important;
    }

    #dashboard .grid.grid-cols-2 > div > .flex > div:last-child {
      padding: 0.3rem !important;
      border-radius: 0.5rem !important;
    }

    #dashboard .grid.grid-cols-2 > div > .flex > div:last-child i {
      width: 1rem !important;
      height: 1rem !important;
    }

    #dashboard .relative.h-80,
    #dashboard #sales-chart-wrapper {
      height: 200px !important;
      min-height: 200px !important;
    }
  }


/* =====================================================
   Desktop-only overrides (≥ 1024px)
   ===================================================== */
@media (min-width: 1024px) {
  /* Hide the Received column in the Sales table on desktop */
  #sale-sales th.lg\:hidden,
  #sale-sales td.lg\:hidden {
    display: none !important;
  }
}
/* =====================================================
   Desktop-only overrides (≥ 1024px)
   ===================================================== */
@media (min-width: 1024px) {
  /* Hide the Received column in the Sales table on desktop */
  #sale-sales th.lg\:hidden,
  #sale-sales td.lg\:hidden {
    display: none !important;
  }
}
  /* ── Info cards: stack to single column ── */
  #sale-details-modal .modal-content .grid,
  #purchase-details-modal .modal-content .grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }

  /* Tighten info card padding */
  #sale-details-modal .modal-content .bg-gray-50,
  #purchase-details-modal .modal-content .bg-gray-50 {
    padding: 0.625rem 0.75rem !important;
    font-size: 0.8rem;
  }

  /* ── Resell details panel ── */
  #view-sale-resell-details {
    padding: 0.625rem 0.75rem !important;
    margin-bottom: 0.75rem !important;
    font-size: 0.8rem;
  }

  /* ── Items / Materials table: horizontal scroll ── */
  #sale-details-modal .modal-content .border.rounded-xl,
  #purchase-details-modal .modal-content .border.rounded-xl {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.75rem !important;
  }

  #view-sale-items-body ~ thead th,
  #sale-details-modal .modal-content table,
  #purchase-details-modal .modal-content table {
    min-width: 380px;
    font-size: 0.75rem !important;
  }

  #sale-details-modal .modal-content thead th,
  #purchase-details-modal .modal-content thead th {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.65rem !important;
  }

  #sale-details-modal .modal-content tbody td,
  #purchase-details-modal .modal-content tbody td {
    padding: 0.5rem 0.75rem !important;
  }

  /* ── Freight/Builty panel ── */
  #view-purchase-freight-details {
    padding: 0.625rem 0.75rem !important;
    margin-bottom: 0.75rem !important;
    font-size: 0.8rem;
  }

  /* ── Totals section: full-width ── */
  #sale-details-modal .modal-content .flex.justify-end,
  #purchase-details-modal .modal-content .flex.justify-end {
    justify-content: stretch !important;
    margin-bottom: 0.75rem !important;
  }

  #sale-details-modal .modal-content .w-full,
  #purchase-details-modal .modal-content .w-full {
    width: 100% !important;
    font-size: 0.8rem;
  }

  /* ── Footer close button: full-width ── */
  #sale-details-modal .modal-content > div:last-child,
  #purchase-details-modal .modal-content > div:last-child {
    flex-direction: column !important;
    gap: 0.5rem !important;
    padding-top: 0.75rem !important;
    margin-top: 0.5rem !important;
  }

  #sale-details-modal .modal-content > div:last-child button,
  #purchase-details-modal .modal-content > div:last-child button {
    width: 100% !important;
    padding: 0.7rem 1rem !important;
    font-size: 0.875rem !important;
    border-radius: 0.75rem !important;
    text-align: center;
  }

  /* ── Hide Description (col 2) & COGS (col 6) from Sale items table ── */
  #sale-details-modal .modal-content table thead tr th:nth-child(2),
  #sale-details-modal .modal-content table tbody tr td:nth-child(2),
  #sale-details-modal .modal-content table thead tr th:nth-child(6),
  #sale-details-modal .modal-content table tbody tr td:nth-child(6) {
    display: none !important;
  }

  /* ── Hide Row Total (col 4) from Purchase materials table ── */
  #purchase-details-modal .modal-content table thead tr th:nth-child(4),
  #purchase-details-modal .modal-content table tbody tr td:nth-child(4) {
    display: none !important;
  }

  /* ── Segmented Control / Single line Subtabs for Sale, Purchase, Reselling, Staff Mgmt, Settings ── */
  #sale > div.flex.flex-wrap,
  #purchase > div.flex.flex-wrap,
  #inv-panel-reselling-items > div.flex.flex-wrap,
  #staff-management > div.flex.flex-wrap,
  #settings > div.flex.flex-wrap,
  #settings-hr > div.flex.flex-wrap {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    padding-bottom: 4px !important;
    margin-bottom: 1rem !important;
    gap: 0.5rem !important;
  }
  
  #sale > div.flex.flex-wrap::-webkit-scrollbar,
  #purchase > div.flex.flex-wrap::-webkit-scrollbar,
  #inv-panel-reselling-items > div.flex.flex-wrap::-webkit-scrollbar,
  #staff-management > div.flex.flex-wrap::-webkit-scrollbar,
  #settings > div.flex.flex-wrap::-webkit-scrollbar,
  #settings-hr > div.flex.flex-wrap::-webkit-scrollbar {
    display: none !important;
  }

  #sale > div.flex.flex-wrap > button,
  #purchase > div.flex.flex-wrap > button,
  #inv-panel-reselling-items > div.flex.flex-wrap > button,
  #staff-management > div.flex.flex-wrap > button,
  #settings > div.flex.flex-wrap > button,
  #settings-hr > div.flex.flex-wrap > button {
    flex: 0 0 auto !important;
    min-width: unset !important;
    padding: 0.55rem 0.85rem !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
    border-radius: 0.75rem !important;
  }

  /* ── My Tasks Module Header: Keep title and filter visible on mobile ── */
  #my-tasks-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.5rem !important;
  }

  #my-tasks-header > div:first-child {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  #my-tasks-header h2 {
    white-space: nowrap !important;
  }

  #mytask-filter-wrapper {
    flex: 0 0 auto !important;
    margin-left: auto !important;
  }

  #my-tasks-header > div:first-child > p {
    display: none !important;
  }

  /* Keep task filters fully inside the mobile viewport. */
  #hr-filter-panel,
  #mytask-filter-panel {
    min-width: 0 !important;
    width: min(240px, calc(100vw - 1rem)) !important;
    max-width: calc(100vw - 1rem) !important;
    box-sizing: border-box !important;
  }

  #hr-filter-panel {
    left: 0 !important;
    right: auto !important;
  }

  #mytask-filter-panel {
    left: auto !important;
    right: 0 !important;
  }

  /* ── My Tasks 4 Summary Counter Cards: 2x2 Grid with small icon in same line as text ── */
  #tasks > div.grid,
  #my-tasks-summary-cards {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
    margin-bottom: 0.75rem !important;
  }

  #tasks > div.grid > div,
  #my-tasks-summary-cards > div {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.625rem 0.75rem !important;
    border-radius: 0.875rem !important;
    gap: 0.35rem !important;
    min-width: 0 !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
  }

  /* Left text details container */
  #tasks > div.grid > div > div:first-child,
  #my-tasks-summary-cards > div > div:first-child {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden !important;
  }

  /* Card label */
  #tasks > div.grid > div > div:first-child > div:first-child,
  #my-tasks-summary-cards > div > div:first-child > div:first-child {
    font-size: 10px !important;
    font-weight: 600 !important;
    color: #64748b !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
  }

  /* Card number / amount */
  #tasks > div.grid > div > div:first-child > div:last-child,
  #my-tasks-summary-cards > div > div:first-child > div:last-child {
    font-size: 14px !important;
    font-weight: 700 !important;
    margin-top: 0.15rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
  }

  /* Right icon container: compact square badge in same line */
  #tasks > div.grid > div > div:last-child,
  #my-tasks-summary-cards > div > div:last-child {
    width: 1.85rem !important;
    height: 1.85rem !important;
    min-width: 1.85rem !important;
    max-width: 1.85rem !important;
    min-height: 1.85rem !important;
    max-height: 1.85rem !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 0.5rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }

  /* Icon inside badge */
  #tasks > div.grid > div > div:last-child svg,
  #tasks > div.grid > div > div:last-child i,
  #my-tasks-summary-cards > div > div:last-child svg,
  #my-tasks-summary-cards > div > div:last-child i {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    max-width: 14px !important;
    min-height: 14px !important;
    max-height: 14px !important;
    display: block !important;
    margin: auto !important;
    stroke-width: 2.2 !important;
    flex-shrink: 0 !important;
  }

  /* ── Tasks & Payroll Filter Bars ── */
  #tasks-board-view > div:first-child,
  #tasks-payroll-view > div:first-child,
  #sm-payroll > div:first-child + div,
  #sm-task-board > div:first-child + div,
  #sm-performance > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  #tasks-board-view > div:first-child button,
  #tasks-payroll-view > div:first-child input[type="month"],
  #sm-payroll input[type="month"],
  #sm-performance input[type="month"],
  #sm-task-board select {
    width: 100% !important;
  }

  /* ── Mobile Card View for Payroll and Commission Tables ── */
  #tasks-payroll-view table,
  #tasks-payroll-view table thead,
  #tasks-payroll-view table tbody,
  #tasks-payroll-view table tr,
  #tasks-payroll-view table td,
  #settings-commission table,
  #settings-commission table thead,
  #settings-commission table tbody,
  #settings-commission table tr,
  #settings-commission table td,
  #sm-performance table,
  #sm-performance table thead,
  #sm-performance table tbody,
  #sm-performance table tr,
  #sm-performance table td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  #tasks-payroll-view table thead,
  #settings-commission table thead,
  #sm-payroll table thead,
  #sm-task-board table thead,
  #sm-performance table thead {
    display: none !important;
  }

  #tasks-payroll-view table tbody tr,
  #settings-commission table tbody tr,
  #sm-performance table tbody tr {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 1rem !important;
    padding: 1rem !important;
    margin-bottom: 0.85rem !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04) !important;
    position: relative !important;
  }

  #tasks-payroll-view .overflow-x-auto,
  #settings-commission .overflow-x-auto,
  #sm-payroll .overflow-x-auto,
  #sm-task-board .overflow-x-auto,
  #sm-performance .overflow-x-auto {
    overflow-x: visible !important;
  }

  /* Staff Payroll Table Cells */
  #tasks-payroll-view table td {
    padding: 0.3rem 0 !important;
    border: none !important;
  }

  #tasks-payroll-view table td:nth-child(1) {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    padding-bottom: 0.5rem !important;
    border-bottom: 1px solid #f1f5f9 !important;
    margin-bottom: 0.5rem !important;
  }

  #tasks-payroll-view table td:nth-child(2):before { content: "Base Salary: "; font-weight: 600; color: #64748b; font-size: 11px; }
  #tasks-payroll-view table td:nth-child(3):before { content: "Bonuses (+): "; font-weight: 600; color: #64748b; font-size: 11px; }
  #tasks-payroll-view table td:nth-child(4):before { content: "Deductions (-): "; font-weight: 600; color: #64748b; font-size: 11px; }
  #tasks-payroll-view table td:nth-child(5):before { content: "Advances (-): "; font-weight: 600; color: #64748b; font-size: 11px; }
  
  #tasks-payroll-view table td:nth-child(6) {
    padding: 0.6rem 0.75rem !important;
    border-radius: 0.75rem !important;
    margin-top: 0.4rem !important;
    margin-bottom: 0.4rem !important;
    font-size: 1rem !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  #tasks-payroll-view table td:nth-child(6):before {
    content: "Net Payable Salary: ";
    font-weight: 700;
    color: #312e81;
    font-size: 12px;
  }

  #tasks-payroll-view table td:last-child {
    padding-top: 0.75rem !important;
    margin-top: 0.5rem !important;
    border-top: 1px solid #f1f5f9 !important;
    text-align: left !important;
  }

  #tasks-payroll-view table td:last-child .flex {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 0.4rem !important;
    width: 100% !important;
  }

  #tasks-payroll-view table td:last-child button {
    flex: 1 1 calc(50% - 0.25rem) !important;
    justify-content: center !important;
    padding: 0.5rem 0.4rem !important;
    font-size: 11px !important;
  }

  /* Settings Commission Rules Table Cells */
  #settings-commission table td {
    padding: 0.35rem 0 !important;
    border: none !important;
  }

  #settings-commission table td:nth-child(1) {
    font-size: 1rem !important;
    font-weight: 700 !important;
    padding-bottom: 0.5rem !important;
    border-bottom: 1px solid #f1f5f9 !important;
    margin-bottom: 0.5rem !important;
  }

  #settings-commission table td:nth-child(2):before { content: "Commission Rate: "; font-weight: 600; color: #64748b; font-size: 11px; }
  #settings-commission table td:nth-child(3):before { content: "Status: "; font-weight: 600; color: #64748b; font-size: 11px; }
  #settings-commission table td:nth-child(4):before { content: "Notes: "; font-weight: 600; color: #64748b; font-size: 11px; }

  #settings-commission table td:last-child {
    padding-top: 0.75rem !important;
    margin-top: 0.5rem !important;
    border-top: 1px solid #f1f5f9 !important;
    text-align: left !important;
  }

  #settings-commission table td:last-child .flex {
    justify-content: flex-start !important;
    gap: 0.5rem !important;
  }

  /* ── Modals Responsiveness (Commission, Payroll, Advance Salary, Tasks) ── */
  #commission-rule-modal .modal-content,
  #sales-commission-modal .modal-content,
  #salary-ledger-modal .modal-content,
  #pay-salary-modal .modal-content,
  #advance-salary-modal .modal-content,
  #task-assign-modal .modal-content,
  #task-submit-modal .modal-content,
  #task-review-modal .modal-content {
    width: 94vw !important;
    max-width: 480px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    border-radius: 1.25rem !important;
    margin: auto !important;
  }
}

/* Dashboard Stat Cards - Responsive Overrides */
@media (max-width: 768px) {
  .dashboard-stat-card {
    padding: 0.85rem 1rem !important;
    border-radius: 1rem !important;
  }
  .dashboard-stat-title {
    font-size: 0.75rem !important;
    margin-bottom: 0.5rem !important;
  }
  .dashboard-stat-inner {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.65rem 0.85rem !important;
    border-radius: 0.75rem !important;
  }
  .dashboard-stat-inner span {
    font-size: 1.15rem !important;
  }
  .dashboard-stat-icon {
    margin-bottom: 0 !important;
  }
  .dashboard-stat-icon i,
  .dashboard-stat-icon svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }
}

@media (max-width: 480px) {
  .dashboard-stat-card {
    padding: 0.65rem 0.65rem !important;
    border-radius: 0.85rem !important;
  }
  .dashboard-stat-title {
    font-size: 0.7rem !important;
    margin-bottom: 0.35rem !important;
  }
  .dashboard-stat-inner {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.5rem 0.65rem !important;
    border-radius: 0.65rem !important;
  }
  .dashboard-stat-inner span {
    font-size: 1.05rem !important;
  }
  .dashboard-stat-icon {
    margin-bottom: 0 !important;
  }
  .dashboard-stat-icon i,
  .dashboard-stat-icon svg {
    width: 1.1rem !important;
    height: 1.1rem !important;
  }
}

/* =====================================================
   My Tasks Section — Mobile Card Layout (≤ 640px)
   ===================================================== */
@media (max-width: 640px) {

  /* Filter bar stack */
  #tasks-board-view > div:first-child {
    flex-direction: column !important;
    gap: 0.65rem !important;
  }
  #task-status-filter {
    width: 100% !important;
  }

  /* Remove horizontal scroll on the table wrapper */
  #tasks-board-view .overflow-x-auto {
    overflow-x: visible !important;
    padding: 0 !important;
  }

  /* Table full-width block */
  #tasks-board-view table {
    width: 100% !important;
    min-width: unset !important;
    border-collapse: separate !important;
    border-spacing: 0 0.6rem !important;
  }

  /* Hide table header */
  #tasks-board-view thead {
    display: none !important;
  }

  /* ── Each row → Sales-style grid card ── */
  #tasks-table-body tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) !important;
    grid-auto-flow: dense !important;
    margin-bottom: 0.875rem !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 1rem !important;
    overflow: hidden !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
    padding: 0 !important;
  }
  #tasks-table-body tr:hover {
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.13) !important;
  }

  /* ── Base cell styles ── */
  #tasks-table-body td {
    display: flex !important;
    flex-direction: column !important;
    padding: 0.625rem 0.875rem !important;
    font-size: 12px !important;
    border-bottom: 1px solid #f3f4f6 !important;
    gap: 0.15rem !important;
    text-align: left !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* ── data-label as small uppercase label above value ── */
  #tasks-table-body td::before {
    content: attr(data-label) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    min-width: unset !important;
    flex-shrink: unset !important;
    margin-bottom: 0.1rem !important;
    text-align: left !important;
  }

  /* ── ROW 1: Task Title (Left) + Type (Right) — Single Line Purple Gradient Header ── */
  #tasks-table-body td[data-label="Task"] {
    grid-column: 1 / 2 !important;
    order: 1 !important;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    padding: 0.625rem 0.5rem 0.625rem 0.875rem !important;
    border-bottom: none !important;
    border-right: none !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    justify-content: center !important;
  }
  #tasks-table-body td[data-label="Task"]::before {
    content: "Task" !important;
    color: rgba(255,255,255,0.75) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
  }
  #tasks-table-body td[data-label="Task"] > div:first-child {
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #tasks-table-body td[data-label="Task"] > div:last-child:not(:first-child) {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 10.5px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #tasks-table-body td[data-label="Type"] {
    grid-column: 2 / 3 !important;
    order: 2 !important;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    padding: 0.625rem 0.875rem 0.625rem 0.25rem !important;
    text-align: right !important;
    align-items: flex-end !important;
    border-bottom: none !important;
    white-space: nowrap !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
  #tasks-table-body td[data-label="Type"]::before {
    content: "Type" !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-align: right !important;
  }
  #tasks-table-body td[data-label="Type"] span {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(4px) !important;
    font-size: 11px !important;
    padding: 0.2rem 0.5rem !important;
    border-radius: 9999px !important;
    white-space: nowrap !important;
  }
  #tasks-table-body td[data-label="Type"] svg {
    color: #ffffff !important;
    width: 12px !important;
    height: 12px !important;
  }

  /* ── ROW 2: Deadline (Left) & Bonus / Fine (Right) — Single Line ── */
  #tasks-table-body td[data-label="Deadline"] {
    grid-column: 1 / 2 !important;
    order: 3 !important;
    color: #374151 !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    padding: 0.5rem 0.75rem !important;
    border-right: 1px solid #f3f4f6 !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: left !important;
    align-items: flex-start !important;
    justify-content: center !important;
    word-break: break-word !important;
    min-width: 0 !important;
  }
  #tasks-table-body td[data-label="Deadline"]::before {
    content: "Deadline" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
  }

  #tasks-table-body td[data-label="Bonus / Fine"] {
    grid-column: 2 / 3 !important;
    order: 4 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 0.5rem 0.75rem !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: right !important;
    align-items: flex-end !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
  #tasks-table-body td[data-label="Bonus / Fine"]::before {
    content: "Bonus / Fine" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    text-align: right !important;
  }
  #tasks-table-body td[data-label="Bonus / Fine"] .bonus-fine-container {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    align-items: center !important;
    font-size: 11px !important;
    gap: 0.2rem !important;
  }

  /* ── ROW 3: Status (Left) & Actions (Right) — Single Line ── */
  #tasks-table-body td[data-label="Status"] {
    grid-column: 1 / 2 !important;
    order: 5 !important;
    background: #f9fafb !important;
    border-bottom: none !important;
    border-top: 1px solid #f3f4f6 !important;
    border-right: none !important;
    padding: 0.5rem 0.75rem !important;
    justify-content: center !important;
    align-items: flex-start !important;
    min-width: 0 !important;
  }
  #tasks-table-body td[data-label="Status"]::before {
    content: "Status" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    text-align: left !important;
    margin-bottom: 0.15rem !important;
  }
  #tasks-table-body td[data-label="Status"] span {
    font-size: 11px !important;
    padding: 0.2rem 0.55rem !important;
    white-space: nowrap !important;
  }

  #tasks-table-body td[data-label="Actions"] {
    grid-column: 2 / 3 !important;
    order: 6 !important;
    background: #f9fafb !important;
    border-bottom: none !important;
    border-top: 1px solid #f3f4f6 !important;
    padding: 0.5rem 0.75rem !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 0.5rem !important;
    min-width: 0 !important;
  }
  #tasks-table-body td[data-label="Actions"]::before {
    display: none !important;
  }
  #tasks-table-body td[data-label="Actions"] .flex {
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
    justify-content: flex-end !important;
    align-items: center !important;
  }
  #tasks-table-body td[data-label="Actions"] button {
    width: auto !important;
    min-height: unset !important;
    padding: 0.35rem 0.75rem !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    border-radius: 0.5rem !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
  }

  /* ── Empty state ── */
  #tasks-table-body tr:has(td[colspan]) {
    display: block !important;
    padding: 2rem 1rem !important;
    text-align: center !important;
    border: 1px dashed #c7d2fe !important;
    background: #fefeff !important;
  }
  #tasks-table-body tr:has(td[colspan]) td {
    display: block !important;
    border-bottom: none !important;
    text-align: center !important;
    justify-content: center !important;
  }
  #tasks-table-body tr:has(td[colspan]) td::before {
    display: none !important;
  }

  /* Summary cards grid: 2 cols on small screens */
  #tasks > .grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }
}

/* =====================================================
   Desktop-only overrides (>= 1024px)
   ===================================================== */
@media (min-width: 1024px) {
  /* Hide the Received column (5th col) in the Sales table on desktop */
  #sales-table-body td:nth-child(5),
  #sale-sales table thead th:nth-child(5) {
    display: none !important;
  }
}

/* =====================================================
   Attendance Module Calendar Mobile Responsive Styling
   ===================================================== */
@media (max-width: 768px) {
  /* Reduce calendar container padding on mobile */
  #my-attendance-calendar-grid > div,
  #attendance-calendar-grid > div {
    padding: 0.75rem !important;
    border-radius: 1.25rem !important;
  }

  /* Compact calendar cells on mobile */
  .att-calendar-cell,
  #my-attendance-calendar-grid .grid-cols-7 > div,
  #attendance-calendar-grid .grid-cols-7 > div {
    height: 3.25rem !important;
    min-height: 3.25rem !important;
    padding: 0.25rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    border-radius: 0.85rem !important;
  }

  /* Center the date number in cell on mobile */
  .att-calendar-cell-header,
  #my-attendance-calendar-grid .grid-cols-7 > div > div:first-child,
  #attendance-calendar-grid .grid-cols-7 > div > div:first-child {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .att-calendar-cell-header span:first-child,
  #my-attendance-calendar-grid .grid-cols-7 > div > div:first-child > span:first-child,
  #attendance-calendar-grid .grid-cols-7 > div > div:first-child > span:first-child {
    font-size: 0.9rem !important;
    text-align: center !important;
  }

  /* Hide status text pill badge on mobile (Present, Late, Leave, Holiday) */
  .att-calendar-status-pill,
  #my-attendance-calendar-grid .grid-cols-7 > div span.rounded-md,
  #attendance-calendar-grid .grid-cols-7 > div span.rounded-md {
    display: none !important;
  }

  /* Hide check-in / check-out times and holiday text titles on mobile */
  .att-calendar-cell-details,
  #my-attendance-calendar-grid .grid-cols-7 > div > div:nth-child(2),
  #attendance-calendar-grid .grid-cols-7 > div > div:nth-child(2) {
    display: none !important;
  }
}

/* =====================================================
   HR Module Mobile Responsiveness — Card Layout
   (Users, Roles, Leave Approvals, Task Board, Payrolls)
   ===================================================== */

/* ── Subtabs scroll bar ────────────────────────────── */
@media (max-width: 768px) {
  #settings-hr > div.flex.flex-wrap,
  #staff-management > div.flex.flex-wrap,
  #settings > div.flex.flex-wrap,
  #att-settings > div.flex.flex-wrap {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem !important;
    margin-bottom: 1rem !important;
    gap: 0.5rem !important;
    width: 100% !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  #settings-hr > div.flex.flex-wrap::-webkit-scrollbar,
  #staff-management > div.flex.flex-wrap::-webkit-scrollbar,
  #settings > div.flex.flex-wrap::-webkit-scrollbar,
  #att-settings > div.flex.flex-wrap::-webkit-scrollbar {
    display: none !important;
  }

  #settings-hr > div.flex.flex-wrap > button,
  #staff-management > div.flex.flex-wrap > button,
  #settings > div.flex.flex-wrap > button,
  #att-settings > div.flex.flex-wrap > button {
    flex: 0 0 auto !important;
    font-size: 0.75rem !important;
    padding: 0.55rem 0.85rem !important;
    white-space: nowrap !important;
    border-radius: 0.75rem !important;
    min-width: unset !important;
  }

  /* ── Filter / header bars ──────────────────────── */
  #settings-payroll .flex-col,
  #settings-task-board .flex-col,
  #sm-payroll .flex-col,
  #sm-task-board .flex-col,
  #sm-performance .flex-col,
  #settings-att-leaves .flex,
  #settings-users .flex,
  #settings-roles .flex {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }
  #settings-task-board .flex-wrap,
  #settings-payroll .flex-wrap,
  #sm-payroll .flex-wrap,
  #sm-task-board .flex-wrap,
  #sm-performance .flex-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.65rem !important;
  }
  #settings-task-board select,
  #settings-payroll input[type="month"],
  #sm-payroll input[type="month"],
  #sm-performance input[type="month"],
  #sm-task-board select {
    width: 100% !important;
  }
  #settings-users > div:first-child + div button,
  #settings-roles > div:first-child + div button,
  #sm-task-board > div:first-child > button {
    width: 100% !important;
    justify-content: center !important;
  }
  #settings-att-leaves > div:first-child > button {
    width: 100% !important;
  }
}

/* =====================================================
   CARD LAYOUT — transforms <table> rows into cards
   on screens ≤ 640px (mobile)
   ===================================================== */
@media (max-width: 640px) {

  /* ── Remove the outer horizontal scroll wrapper ── */
  #settings-users .overflow-x-auto,
  #settings-roles .overflow-x-auto,
  #settings-att-leaves .overflow-x-auto,
  #settings-att-holidays .overflow-x-auto,
  #settings-payroll .overflow-x-auto,
  #settings-task-board .overflow-x-auto,
  #sm-payroll .overflow-x-auto,
  #sm-task-board .overflow-x-auto,
  #sm-performance .overflow-x-auto {
    overflow-x: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Make table & tbody full-width block ─────────────── */
  #settings-users table,
  #settings-roles table,
  #settings-att-leaves table,
  #settings-att-holidays table,
  #settings-payroll table,
  #sm-payroll table,
  #sm-task-board table,
  #sm-performance table,
  #settings-users table tbody,
  #settings-roles table tbody,
  #settings-att-leaves table tbody,
  #settings-att-holidays table tbody,
  #settings-payroll table tbody,
  #sm-payroll table tbody,
  #sm-task-board table tbody,
  #sm-performance table tbody,
  #payroll-table-body,
  #hr-tasks-table-body {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 0.6rem !important;
    display: block !important;
    box-sizing: border-box !important;
  }

  /* ── Hide table header on mobile ─────────────── */
  #settings-users thead,
  #settings-roles thead,
  #settings-att-leaves thead,
  #settings-att-holidays thead,
  #settings-payroll thead,
  #settings-task-board thead,
  #sm-payroll thead,
  #sm-task-board thead,
  #sm-performance thead,
  #sm-payroll table thead,
  #sm-task-board table thead,
  #sm-performance table thead,
  #payroll-table-body ~ thead,
  #hr-tasks-table-body ~ thead,
  #users-table-body ~ thead {
    display: none !important;
  }

  /* ── Each <tr> becomes a card ─────────────────── */
  #users-table-body tr,
  #roles-table-body tr,
  #admin-leaves-table-body tr,
  #admin-holidays-table-body tr,
  #perf-table-body tr,
  #commission-rules-table-body tr {
    display: block !important;
    background: #ffffff !important;
    border: 1px solid #e9e5f3 !important;
    border-radius: 1.1rem !important;
    box-shadow: 0 4px 14px rgba(88, 28, 135, 0.07) !important;
    margin-bottom: 0.85rem !important;
    padding: 0.85rem 1rem !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    width: 100% !important;
  }
  #users-table-body tr:hover,
  #roles-table-body tr:hover,
  #admin-leaves-table-body tr:hover,
  #admin-holidays-table-body tr:hover,
  #perf-table-body tr:hover {
    background: #faf5ff !important;
    box-shadow: 0 6px 18px rgba(88, 28, 135, 0.12) !important;
  }

  /* ── Each <td> becomes a label:value row ──────── */
  #users-table-body td,
  #roles-table-body td,
  #admin-leaves-table-body td,
  #admin-holidays-table-body td,
  #perf-table-body td,
  #commission-rules-table-body td {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    padding: 0.45rem 0 !important;
    font-size: 0.8rem !important;
    border-bottom: 1px dashed #f0eaf8 !important;
    line-height: 1.4 !important;
    gap: 0.5rem !important;
    text-align: right !important;
    box-sizing: border-box !important;
    width: 100% !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }
  #users-table-body td:last-child,
  #roles-table-body td:last-child,
  #admin-leaves-table-body td:last-child,
  #admin-holidays-table-body td:last-child,
  #perf-table-body td:last-child,
  #commission-rules-table-body td:last-child {
    border-bottom: none !important;
    padding-bottom: 0 !important;
  }

  /* ── data-label as the left-side label ─────────── */
  #users-table-body td::before,
  #roles-table-body td::before,
  #admin-leaves-table-body td::before,
  #admin-holidays-table-body td::before,
  #perf-table-body td::before,
  #commission-rules-table-body td::before {
    content: attr(data-label) !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    color: #7c3aed !important;
    white-space: nowrap !important;
    min-width: 90px !important;
    flex-shrink: 0 !important;
    padding-top: 0.1rem !important;
    text-align: left !important;
  }

  /* ── Action buttons row: full-width row of buttons ─ */
  #users-table-body td.table-cell-actions,
  #users-table-body td[data-label="Actions"],
  #roles-table-body td.table-cell-actions,
  #roles-table-body td[data-label="Actions"],
  #admin-leaves-table-body td:last-child,
  #admin-leaves-table-body td[data-label="Actions"],
  #perf-table-body td:last-child,
  #perf-table-body td[data-label="Actions"] {
    justify-content: space-between !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
    padding-top: 0.6rem !important;
    margin-top: 0.25rem !important;
    border-top: 1px dashed #f0eaf8 !important;
    border-bottom: none !important;
    width: 100% !important;
  }
  #users-table-body td.table-cell-actions .flex,
  #users-table-body td[data-label="Actions"] .flex,
  #roles-table-body td.table-cell-actions .flex,
  #roles-table-body td[data-label="Actions"] .flex {
    flex-wrap: wrap !important;
    gap: 0.4rem !important;
    justify-content: flex-end !important;
    max-width: 100% !important;
  }

  /* ── Compact buttons inside action cells ──────── */
  #users-table-body td button,
  #roles-table-body td button,
  #admin-leaves-table-body td button,
  #perf-table-body td button {
    font-size: 0.72rem !important;
    padding: 0.35rem 0.75rem !important;
    border-radius: 0.6rem !important;
    white-space: nowrap !important;
  }

  /* ── Empty state rows stay centered ───────────── */
  #users-table-body tr:has(td[colspan]),
  #roles-table-body tr:has(td[colspan]),
  #admin-leaves-table-body tr:has(td[colspan]),
  #perf-table-body tr:has(td[colspan]) {
    display: block !important;
    padding: 2rem 1rem !important;
    text-align: center !important;
    border: 1px dashed #e0d5f5 !important;
    background: #fdfbff !important;
  }
  #users-table-body tr:has(td[colspan]) td,
  #roles-table-body tr:has(td[colspan]) td,
  #admin-leaves-table-body tr:has(td[colspan]) td,
  #perf-table-body tr:has(td[colspan]) td {
    display: block !important;
    border-bottom: none !important;
    text-align: center !important;
    justify-content: center !important;
  }
  #users-table-body tr:has(td[colspan]) td::before,
  #roles-table-body tr:has(td[colspan]) td::before,
  #admin-leaves-table-body tr:has(td[colspan]) td::before,
  #perf-table-body tr:has(td[colspan]) td::before {
    display: none !important;
  }

  /* ── Roles & Users: permissions cell wraps nicely ──────── */
  #users-table-body td[data-label="Role & Permissions"],
  #roles-table-body td[data-label="Permissions"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.25rem !important;
    text-align: left !important;
  }
  #users-table-body td[data-label="Role & Permissions"]::before,
  #roles-table-body td[data-label="Permissions"]::before {
    margin-bottom: 0.2rem !important;
  }

  /* ── Task Board: status badges & proof links — handled in grid section below ─── */

  /* ── Header cells in card views ────────────────── */
  #admin-leaves-table-body td[data-label="Employee"],
  #perf-table-body td[data-label="Staff Member"],
  #users-table-body td[data-label="User & Credentials"],
  #users-table-body td[data-label="Username"],
  #roles-table-body td[data-label="Role Name"] {
    border-bottom: 1px solid #ddd6fe !important;
    padding-bottom: 0.55rem !important;
    margin-bottom: 0.25rem !important;
    font-weight: 700 !important;
    font-size: 0.88rem !important;
    color: #4c1d95 !important;
  }

  /* ── Leave: date range & type compact ─────────── */
  #admin-leaves-table-body td[data-label="Dates"] {
    font-size: 0.75rem !important;
  }

  /* ── Holidays table card adjustments ──────────── */
  #admin-holidays-table-body tr {
    border-left: 3px solid #7c3aed !important;
  }
  #admin-holidays-table-body td:last-child {
    justify-content: flex-end !important;
  }
  #admin-holidays-table-body td:last-child::before {
    display: none !important;
  }

  /* ── Commission table cards ───────────────────── */
  #commission-rules-table-body tr {
    display: block !important;
    background: #ffffff !important;
    border: 1px solid #e9e5f3 !important;
    border-radius: 1.1rem !important;
    box-shadow: 0 2px 10px rgba(88, 28, 135, 0.07) !important;
    margin-bottom: 0.75rem !important;
    padding: 0.85rem 1rem !important;
  }
  #commission-rules-table-body td {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    padding: 0.45rem 0 !important;
    font-size: 0.8rem !important;
    border-bottom: 1px dashed #f0eaf8 !important;
    gap: 0.5rem !important;
    text-align: right !important;
  }
  #commission-rules-table-body td:last-child {
    border-bottom: none !important;
  }
  #commission-rules-table-body td::before {
    content: attr(data-label) !important;
    font-size: 0.68rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    color: #7c3aed !important;
    white-space: nowrap !important;
    min-width: 90px !important;
    flex-shrink: 0 !important;
    text-align: left !important;
  }
}

/* =====================================================
   HR Tasks Table (#hr-tasks-table-body) — Mobile Cards
   2-column grid card on screens ≤ 640px matching My Tasks
   Row 1: Task (left) + Type (right) - Purple gradient banner
   Row 2: Assigned To (left) + Deadline (right)
   Row 3: Bonus / Fine (left) + Proof (right)
   Row 4: Status (left) + Actions (right)
   ===================================================== */
@media (max-width: 640px) {

  /* ── Full width table & remove container outer box on mobile ── */
  #sm-task-board .overflow-x-auto {
    overflow-x: visible !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  #sm-task-board table,
  #sm-task-board table tbody,
  #hr-tasks-table-body {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Grid card shell ── */
  #hr-tasks-table-body tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) !important;
    margin-bottom: 0.875rem !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 1rem !important;
    overflow: hidden !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  #hr-tasks-table-body tr:hover {
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.13) !important;
  }

  /* ── Empty state: override grid back to block ── */
  #hr-tasks-table-body tr:has(td[colspan]) {
    display: block !important;
    padding: 2rem 1rem !important;
    text-align: center !important;
    border: 1px dashed #c7d2fe !important;
    background: #fefeff !important;
  }
  #hr-tasks-table-body tr:has(td[colspan]) td {
    display: block !important;
    border-bottom: none !important;
    text-align: center !important;
    justify-content: center !important;
  }
  #hr-tasks-table-body tr:has(td[colspan]) td::before {
    display: none !important;
  }

  /* ── Base cell ── */
  #hr-tasks-table-body td {
    display: flex !important;
    flex-direction: column !important;
    padding: 0.625rem 0.875rem !important;
    font-size: 12px !important;
    border-bottom: 1px solid #f3f4f6 !important;
    gap: 0.15rem !important;
    text-align: left !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    word-break: break-word !important;
    min-width: 0 !important;
  }

  /* ── data-label: small gray uppercase above value ── */
  #hr-tasks-table-body td::before {
    content: attr(data-label) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    min-width: unset !important;
    flex-shrink: unset !important;
    margin-bottom: 0.1rem !important;
    text-align: left !important;
  }

  /* ── ROW 1: Task Title (Left) + Type (Right) — Single Line Purple Gradient Header ── */
  #hr-tasks-table-body td[data-label="Task"] {
    grid-column: 1 / 2 !important;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    padding: 0.625rem 0.5rem 0.625rem 0.875rem !important;
    border-bottom: none !important;
    border-right: none !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    justify-content: center !important;
  }
  #hr-tasks-table-body td[data-label="Task"]::before {
    content: "Task" !important;
    color: rgba(255,255,255,0.75) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
  }
  #hr-tasks-table-body td[data-label="Task"] > div:first-child {
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #hr-tasks-table-body td[data-label="Task"] > div:last-child:not(:first-child) {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 10.5px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #hr-tasks-table-body td[data-label="Type"] {
    grid-column: 2 / 3 !important;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    padding: 0.625rem 0.875rem 0.625rem 0.25rem !important;
    text-align: right !important;
    align-items: flex-end !important;
    border-bottom: none !important;
    white-space: nowrap !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
  #hr-tasks-table-body td[data-label="Type"]::before {
    content: "Type" !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-align: right !important;
  }
  #hr-tasks-table-body td[data-label="Type"] span {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(4px) !important;
    font-size: 11px !important;
    padding: 0.2rem 0.5rem !important;
    border-radius: 9999px !important;
    white-space: nowrap !important;
  }
  #hr-tasks-table-body td[data-label="Type"] svg {
    color: #ffffff !important;
    width: 12px !important;
    height: 12px !important;
  }

  /* ── ROW 2: Assigned To (Left) & Deadline (Right) — Single Line ── */
  #hr-tasks-table-body td[data-label="Assigned To"] {
    grid-column: 1 / 2 !important;
    color: #1f2937 !important;
    padding: 0.5rem 0.75rem !important;
    border-right: 1px solid #f3f4f6 !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: left !important;
    align-items: flex-start !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  #hr-tasks-table-body td[data-label="Assigned To"]::before {
    content: "Assigned To" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
  }
  #hr-tasks-table-body td[data-label="Assigned To"] > div:first-child {
    font-weight: 600 !important;
    font-size: 12px !important;
    color: #111827 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }
  #hr-tasks-table-body td[data-label="Assigned To"] > div:last-child:not(:first-child) {
    font-size: 10px !important;
    color: #9ca3af !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
  }

  #hr-tasks-table-body td[data-label="Deadline"] {
    grid-column: 2 / 3 !important;
    color: #374151 !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    padding: 0.5rem 0.75rem !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: right !important;
    align-items: flex-end !important;
    justify-content: center !important;
    word-break: break-word !important;
    min-width: 0 !important;
  }
  #hr-tasks-table-body td[data-label="Deadline"]::before {
    content: "Deadline" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    text-align: right !important;
  }
  #hr-tasks-table-body td[data-label="Deadline"] span {
    text-align: right !important;
  }

  /* ── ROW 3: Bonus / Fine (Left) & Proof (Right) — Single Line ── */
  #hr-tasks-table-body td[data-label="Bonus / Fine"] {
    grid-column: 1 / 2 !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 0.5rem 0.75rem !important;
    border-right: 1px solid #f3f4f6 !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: left !important;
    align-items: flex-start !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
  #hr-tasks-table-body td[data-label="Bonus / Fine"]::before {
    content: "Bonus / Fine" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    text-align: left !important;
  }
  #hr-tasks-table-body td[data-label="Bonus / Fine"] .bonus-fine-container {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    align-items: center !important;
    font-size: 11px !important;
    gap: 0.2rem !important;
  }

  #hr-tasks-table-body td[data-label="Proof"] {
    grid-column: 2 / 3 !important;
    font-size: 11px !important;
    padding: 0.5rem 0.75rem !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: right !important;
    align-items: flex-end !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  #hr-tasks-table-body td[data-label="Proof"]::before {
    content: "Proof" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    text-align: right !important;
  }
  #hr-tasks-table-body td[data-label="Proof"] .flex {
    align-items: flex-end !important;
    max-width: 100% !important;
  }
  #hr-tasks-table-body td[data-label="Proof"] a {
    font-size: 11px !important;
    white-space: nowrap !important;
  }
  #hr-tasks-table-body td[data-label="Proof"] span {
    text-align: right !important;
    max-width: 100% !important;
  }

  /* ── ROW 4: Status (Left) & Actions Icons (Right) — Single Line ── */
  #hr-tasks-table-body td[data-label="Status"] {
    grid-column: 1 / 2 !important;
    background: #f9fafb !important;
    border-bottom: none !important;
    border-top: 1px solid #f3f4f6 !important;
    border-right: none !important;
    padding: 0.5rem 0.75rem !important;
    justify-content: center !important;
    align-items: flex-start !important;
    min-width: 0 !important;
  }
  #hr-tasks-table-body td[data-label="Status"]::before {
    content: "Status" !important;
    font-size: 9.5px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    text-align: left !important;
    margin-bottom: 0.15rem !important;
  }
  #hr-tasks-table-body td[data-label="Status"] span {
    font-size: 11px !important;
    padding: 0.2rem 0.55rem !important;
    white-space: nowrap !important;
  }

  #hr-tasks-table-body td[data-label="Actions"] {
    grid-column: 2 / 3 !important;
    background: #f9fafb !important;
    border-bottom: none !important;
    border-top: 1px solid #f3f4f6 !important;
    padding: 0.5rem 0.75rem !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
  }
  #hr-tasks-table-body td[data-label="Actions"]::before {
    display: none !important;
  }
  #hr-tasks-table-body td[data-label="Actions"] .flex {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    justify-content: flex-end !important;
    align-items: center !important;
    width: auto !important;
  }
  #hr-tasks-table-body td[data-label="Actions"] button {
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    max-width: 2rem !important;
    min-height: 2rem !important;
    max-height: 2rem !important;
    aspect-ratio: 1 / 1 !important;
    padding: 0 !important;
    font-size: 11px !important;
    border-radius: 0.55rem !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
  }
  #hr-tasks-table-body td[data-label="Actions"] button svg,
  #hr-tasks-table-body td[data-label="Actions"] button i,
  #hr-tasks-table-body td[data-label="Actions"] button svg.lucide {
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    max-width: 15px !important;
    min-height: 15px !important;
    max-height: 15px !important;
    margin: auto !important;
    display: block !important;
    stroke-width: 2.2 !important;
    flex-shrink: 0 !important;
  }
  /* Hide button text on mobile so action buttons become neat icons in a single line */
  #hr-tasks-table-body td[data-label="Actions"] .hr-btn-text {
    display: none !important;
  }
}

/* =====================================================
   Staff Payroll Table (#payroll-table-body) — Mobile Cards
   3-column grid card on screens ≤ 640px matching Task Board
   Row 1: Staff Member (cols 1-2) + Base Salary (col 3) — Purple gradient banner
   Row 2: Bonuses (col 1) + Deductions (col 2) + Advances (col 3) — White row in single line
   Row 3: Net Salary (col 1) + Actions (cols 2-3) — Light gray footer in single line
   ===================================================== */
@media (max-width: 640px) {

  /* ── Full width table & remove container outer box on mobile ── */
  #sm-payroll .overflow-x-auto {
    overflow-x: visible !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  #sm-payroll table,
  #sm-payroll table tbody,
  #payroll-table-body {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Grid card shell ── */
  #payroll-table-body tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) !important;
    margin-bottom: 0.875rem !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 1rem !important;
    overflow: hidden !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  #payroll-table-body tr:hover {
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.13) !important;
  }

  /* ── Empty state: override grid back to block ── */
  #payroll-table-body tr:has(td[colspan]) {
    display: block !important;
    padding: 2rem 1rem !important;
    text-align: center !important;
    border: 1px dashed #c7d2fe !important;
    background: #fefeff !important;
  }
  #payroll-table-body tr:has(td[colspan]) td {
    display: block !important;
    border-bottom: none !important;
    text-align: center !important;
    justify-content: center !important;
  }
  #payroll-table-body tr:has(td[colspan]) td::before {
    display: none !important;
  }

  /* ── Base cell ── */
  #payroll-table-body td {
    display: flex !important;
    flex-direction: column !important;
    padding: 0.5rem 0.65rem !important;
    font-size: 12px !important;
    border-bottom: 1px solid #f3f4f6 !important;
    gap: 0.15rem !important;
    text-align: left !important;
    line-height: 1.4 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    word-break: break-word !important;
    min-width: 0 !important;
  }

  /* ── data-label: small gray uppercase above value ── */
  #payroll-table-body td::before {
    content: attr(data-label) !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    min-width: unset !important;
    flex-shrink: unset !important;
    margin-bottom: 0.1rem !important;
    text-align: left !important;
  }

  /* ── ROW 1: Staff Member (Cols 1-2) + Base Salary (Col 3) — Single Line Purple Gradient Header ── */
  #payroll-table-body td[data-label="Staff Member"] {
    grid-column: 1 / 3 !important;
    background: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    padding: 0.625rem 0.5rem 0.625rem 0.875rem !important;
    border-bottom: none !important;
    border-right: none !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    justify-content: center !important;
  }
  #payroll-table-body td[data-label="Staff Member"]::before {
    content: "Staff Member" !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
  }
  #payroll-table-body td[data-label="Staff Member"] > div:first-child {
    color: #ffffff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #payroll-table-body td[data-label="Staff Member"] > div:last-child:not(:first-child) {
    color: rgba(255, 255, 255, 0.85) !important;
    font-size: 10.5px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  #payroll-table-body td[data-label="Base Salary"] {
    grid-column: 3 / 4 !important;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    padding: 0.625rem 0.875rem 0.625rem 0.25rem !important;
    text-align: right !important;
    align-items: flex-end !important;
    border-bottom: none !important;
    white-space: nowrap !important;
    justify-content: center !important;
    min-width: 0 !important;
  }
  #payroll-table-body td[data-label="Base Salary"]::before {
    content: "Base Salary" !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    text-align: right !important;
  }

  /* ── ROW 2: Bonuses (Col 1), Deductions (Col 2), Advances (Col 3) — Single Line ── */
  #payroll-table-body td[data-label="Bonuses"] {
    grid-column: 1 / 2 !important;
    color: #059669 !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    padding: 0.5rem 0.65rem 0.5rem 0.875rem !important;
    border-right: 1px solid #f3f4f6 !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: left !important;
    align-items: flex-start !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #payroll-table-body td[data-label="Bonuses"]::before {
    content: "Bonuses" !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
  }

  #payroll-table-body td[data-label="Deductions"] {
    grid-column: 2 / 3 !important;
    color: #e11d48 !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    padding: 0.5rem 0.65rem !important;
    border-right: 1px solid #f3f4f6 !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: center !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #payroll-table-body td[data-label="Deductions"]::before {
    content: "Deductions" !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    text-align: center !important;
  }

  #payroll-table-body td[data-label="Advances"] {
    grid-column: 3 / 4 !important;
    color: #d97706 !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    padding: 0.5rem 0.875rem 0.5rem 0.65rem !important;
    border-bottom: 1px solid #e5e7eb !important;
    background: #ffffff !important;
    text-align: right !important;
    align-items: flex-end !important;
    justify-content: center !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #payroll-table-body td[data-label="Advances"]::before {
    content: "Advances" !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #9ca3af !important;
    white-space: nowrap !important;
    text-align: right !important;
  }

  /* ── ROW 3: Net Salary (Col 1) & Actions (Cols 2-3) — Single Line Footer ── */
  #payroll-table-body td[data-label="Net Salary"],
  #payroll-table-body td[data-label="Net Payable"],
  #payroll-table-body td[data-label="Net Payable Salary"] {
    grid-column: 1 / 2 !important;
    background: #f9fafb !important;
    border-bottom: none !important;
    border-top: 1px solid #f3f4f6 !important;
    border-right: none !important;
    padding: 0.5rem 0.65rem 0.5rem 0.875rem !important;
    justify-content: center !important;
    align-items: flex-start !important;
    min-width: 0 !important;
    color: #4338ca !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  #payroll-table-body td[data-label="Net Salary"]::before,
  #payroll-table-body td[data-label="Net Payable"]::before,
  #payroll-table-body td[data-label="Net Payable Salary"]::before {
    content: "Net Salary" !important;
    font-size: 9px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #6b7280 !important;
    text-align: left !important;
    margin-bottom: 0.1rem !important;
  }

  #payroll-table-body td[data-label="Actions"] {
    grid-column: 2 / 4 !important;
    background: #f9fafb !important;
    border-bottom: none !important;
    border-top: 1px solid #f3f4f6 !important;
    padding: 0.5rem 0.875rem 0.5rem 0.5rem !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  #payroll-table-body td[data-label="Actions"]::before {
    display: none !important;
  }
  #payroll-table-body td[data-label="Actions"] .flex {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.35rem !important;
    justify-content: flex-end !important;
    align-items: center !important;
    width: auto !important;
  }
  #payroll-table-body td[data-label="Actions"] button {
    width: 2rem !important;
    height: 2rem !important;
    min-width: 2rem !important;
    max-width: 2rem !important;
    min-height: 2rem !important;
    max-height: 2rem !important;
    aspect-ratio: 1 / 1 !important;
    padding: 0 !important;
    font-size: 11px !important;
    border-radius: 0.55rem !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
  }
  #payroll-table-body td[data-label="Actions"] button svg,
  #payroll-table-body td[data-label="Actions"] button i,
  #payroll-table-body td[data-label="Actions"] button svg.lucide {
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    max-width: 15px !important;
    min-height: 15px !important;
    max-height: 15px !important;
    margin: auto !important;
    display: block !important;
    stroke-width: 2.2 !important;
    flex-shrink: 0 !important;
  }
}

/* WhatsApp Connect: Hide PC Chrome Extension card on mobile screens (keep Mobile App & Activation Key visible) */
@media (max-width: 768px) {
  #crm-pc-extension-card {
    display: none !important;
  }
}

