/* Almajad CRM 3.6.28 — finance mobile data tables.
   Pure presentation update. No data/payment/permission changes. */

/* On desktops/tablets, keep full tables with an isolated horizontal scroll when necessary. */
#finance-today .table-scroll,
.crm354-report-filters + .table-scroll,
.table-scroll:has(> table.crm354-fin-table) {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
#finance-today .crm359-table { min-width: 920px; width: 100%; table-layout: auto; }
#finance-today .crm359-table th,
#finance-today .crm359-table td { word-break: normal; overflow-wrap: break-word; line-height: 1.6; }
#finance-today .crm359-table .crm359-review-form { min-width: 150px; }
.crm354-fin-table { min-width: 720px; width: 100%; }

@media (max-width: 767px) {
  #finance-today,
  #finance-today .table-scroll,
  #finance-today .panel-heading,
  .table-scroll:has(> table.crm354-fin-table) {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  #finance-today { padding: 14px 12px !important; }
  #finance-today .panel-heading { display: block !important; }
  #finance-today .panel-heading h3 { font-size: clamp(17px, 4.6vw, 22px); line-height: 1.65; }
  #finance-today .crm359-today-overview { gap: 8px !important; }
  #finance-today .crm359-today-overview strong { font-size: 13px; padding: 7px 11px; }

  /* Every payment becomes a separate, legible card instead of squeezed columns. */
  #finance-today table.crm359-table,
  #finance-today table.crm359-table tbody,
  #finance-today table.crm359-table tbody tr,
  .table-scroll table.crm354-fin-table,
  .table-scroll table.crm354-fin-table tbody,
  .table-scroll table.crm354-fin-table tbody tr {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    table-layout: auto !important;
    border-collapse: separate !important;
  }
  #finance-today .crm359-table thead,
  .table-scroll .crm354-fin-table thead { display: none !important; }

  #finance-today .crm359-table tbody tr,
  .table-scroll .crm354-fin-table tbody tr {
    padding: 10px 12px !important;
    margin: 10px 0 !important;
    border: 1px solid #dce9ef !important;
    border-radius: 15px !important;
    background: #fff !important;
    box-shadow: 0 5px 18px rgba(18, 64, 83, .055) !important;
  }
  #finance-today .crm359-table tbody td,
  .table-scroll .crm354-fin-table tbody td {
    display: flex !important;
    gap: 9px !important;
    flex-wrap: wrap !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    text-align: start !important;
    padding: 9px 2px !important;
    margin: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    border: 0 !important;
    border-bottom: 1px solid #edf3f5 !important;
    white-space: normal !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    font-size: 13px !important;
    line-height: 1.7 !important;
  }
  #finance-today .crm359-table tbody td:last-child,
  .table-scroll .crm354-fin-table tbody td:last-child { border-bottom: 0 !important; }
  #finance-today .crm359-table tbody td::before,
  .table-scroll .crm354-fin-table tbody td::before {
    display: block;
    flex: 0 0 100px;
    max-width: 42%;
    font-size: 12px;
    font-weight: 800;
    color: #668498;
    line-height: 1.6;
    text-align: right;
    white-space: normal;
  }
  #finance-today .crm359-table tbody td:nth-child(1)::before { content: 'رقم العملية'; }
  #finance-today .crm359-table tbody td:nth-child(2)::before { content: 'العميل'; }
  #finance-today .crm359-table tbody td:nth-child(3)::before { content: 'الجوال'; }
  #finance-today .crm359-table tbody td:nth-child(4)::before { content: 'الخدمة'; }
  #finance-today .crm359-table tbody td:nth-child(5)::before { content: 'القسم'; }
  #finance-today .crm359-table tbody td:nth-child(6)::before { content: 'المبلغ'; }
  #finance-today .crm359-table tbody td:nth-child(7)::before { content: 'تاريخ القبض'; }
  #finance-today .crm359-table tbody td:nth-child(8)::before { content: 'صاحبة الإيراد'; }
  #finance-today .crm359-table tbody td:nth-child(9)::before { content: 'سجلتها'; }
  #finance-today .crm359-table tbody td:nth-child(10)::before { content: 'مراجعة الفاتورة'; }
  .table-scroll .crm354-fin-table tbody td:nth-child(1)::before { content: 'العميل'; }
  .table-scroll .crm354-fin-table tbody td:nth-child(2)::before { content: 'الخدمة'; }
  .table-scroll .crm354-fin-table tbody td:nth-child(3)::before { content: 'القسم'; }
  .table-scroll .crm354-fin-table tbody td:nth-child(4)::before { content: 'المبلغ'; }
  .table-scroll .crm354-fin-table tbody td:nth-child(5)::before { content: 'وقت الدفع'; }
  .table-scroll .crm354-fin-table tbody td:nth-child(6)::before { content: 'صاحبة الإيراد'; }
  /* Empty tables have a plain full-width notice, not a row with fictitious labels. */
  #finance-today .crm359-table tbody td[colspan],
  .table-scroll .crm354-fin-table tbody td[colspan] {
    display: block !important;
    text-align: center !important;
    color: #637d8e !important;
    padding: 16px 6px !important;
    font-size: 14px !important;
  }
  #finance-today .crm359-table tbody td[colspan]::before,
  .table-scroll .crm354-fin-table tbody td[colspan]::before { content: none !important; display: none !important; }
  #finance-today .crm359-table td[dir='ltr'],
  .table-scroll .crm354-fin-table td[dir='ltr'] {
    direction: rtl !important;
    unicode-bidi: normal;
  }
  #finance-today .crm359-table td[dir='ltr']::first-line,
  .table-scroll .crm354-fin-table td[dir='ltr']::first-line { direction: ltr; }
  #finance-today .crm359-table .crm359-review-form {
    display: grid !important;
    grid-template-columns: minmax(0,1fr);
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 10px 0 0 !important;
  }
  #finance-today .crm359-table .crm359-review-form input,
  #finance-today .crm359-table .crm359-review-form select,
  #finance-today .crm359-table .crm359-review-form button {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 42px;
    box-sizing: border-box;
  }
  #finance-today .crm359-table tbody td:last-child {
    display: block !important;
  }
  #finance-today .crm359-table tbody td:last-child::before {
    margin-bottom: 8px;
    max-width: none;
  }
  #finance-today .crm359-review,
  #finance-today .crm359-paid { display: inline-flex !important; width: auto !important; max-width: 100% !important; white-space: normal !important; overflow-wrap: normal !important; word-break: normal !important; line-height: 1.7; }
  #finance-today .crm359-table .btn { white-space: normal !important; text-align: center; }
}
