/* Tarun Sangha v7.2.9 - consistent tables across management modules.
   Mobile cards apply only to simple data tables; complex ledgers remain scrollable.
   Print keeps the native table, headers and column alignment. */
.ts-data-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border-radius: 11px;
}
.ts-data-table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  color: #17253d;
  font-size: .83rem;
  line-height: 1.45;
}
.ts-data-table > thead > tr > th,
.ts-data-table > thead > tr > td {
  background: #f3f7fc !important;
  color: #49617e !important;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .015em;
  padding: .78rem .82rem !important;
  border-bottom: 1px solid #dbe5f0 !important;
  white-space: nowrap;
  vertical-align: middle;
}
.ts-data-table > tbody > tr > td,
.ts-data-table > tbody > tr > th {
  padding: .8rem .82rem !important;
  vertical-align: middle;
  border-bottom: 1px solid #e8eef5;
  transition: background-color .12s ease;
}
.ts-data-table > tbody > tr:nth-child(even) { background: #fbfdff; }
.ts-data-table > tbody > tr:hover { background: #f3f8ff; }
.ts-data-table > tbody > tr:last-child > td { border-bottom: none; }
.ts-data-table td, .ts-data-table th { overflow-wrap: anywhere; }
.ts-data-table .badge { max-width: 100%; white-space: normal; }
.ts-data-table :is(button, a):focus-visible,
.ts-table-actions > summary:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

/* Preserve native Angular action handlers: visually hide only the original
   rendered row controls, and trigger them through menu proxy buttons. */
.ts-data-table td.ts-actions-ready > :not(details.ts-table-actions),
.ts-data-table th.ts-actions-ready > :not(details.ts-table-actions) { display: none !important; }
.ts-data-table td.ts-actions-ready { text-align: right; }
.ts-table-actions { display: inline-block; position: relative; font: inherit; color: #1e3a5f; text-align: left; }
.ts-table-actions > summary {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .48rem; border: 1px solid #c5d5e9; border-radius: 9px;
  background: #fff; color: #1d4ed8; padding: .47rem .76rem;
  min-width: 92px; min-height: 38px; font-size: .79rem;
  font-weight: 750; cursor: pointer; list-style: none; user-select: none;
  transition: background-color .15s, border-color .15s;
}
.ts-table-actions > summary::-webkit-details-marker { display: none; }
.ts-table-actions > summary::after { content: '▾'; color: #5075af; font-size: .8rem; }
.ts-table-actions[open] > summary { background: #eef5ff; border-color: #88b4ef; }
.ts-table-actions[open] > summary::after { content: '▴'; }
.ts-table-actions-menu {
  position: fixed; left: 0; top: 0; z-index: 2147481000;
  width: min(264px, calc(100vw - 16px));
  max-height: min(420px, calc(100dvh - 16px));
  overflow: auto; overscroll-behavior: contain; padding: 6px;
  border-radius: 12px; border: 1px solid #d9e4f1;
  box-shadow: 0 15px 40px rgba(19, 37, 67, .21);
  background: #fff;
}
.ts-table-actions:not([open]) > .ts-table-actions-menu { display: none !important; }
.ts-table-actions-menu > button.ts-table-action-item {
  width: 100% !important; display: block !important; text-align: left !important;
  min-height: 39px; padding: .65rem .75rem !important;
  margin: 0 !important; border: 0 !important; border-radius: 8px !important;
  background: transparent !important; color: #1d304a !important;
  font: 600 .82rem/1.4 inherit; font-size: .82rem !important;
  font-weight: 650 !important; white-space: normal !important;
  cursor: pointer; box-shadow: none !important;
}
.ts-table-actions-menu > button:hover,
.ts-table-actions-menu > button:focus-visible { background: #eff6ff !important; color: #1d4ed8 !important; }
.ts-table-actions-menu > button.ts-table-action-danger { color: #b91c1c !important; }
.ts-table-actions-menu > button.ts-table-action-danger:hover { background: #fff1f2 !important; }
.ts-table-actions-menu > button:disabled { color: #9aa8ba !important; cursor: not-allowed; opacity: .55; }

@media (max-width: 720px) {
  .ts-data-table-wrap:has(.ts-mobile-card-table) {
    border: 0 !important; box-shadow: none !important;
    overflow: visible !important; padding: 2px 0 5px;
  }
  .ts-data-table.ts-mobile-card-table {
    min-width: 0 !important; width: 100% !important; display: block !important;
    border: 0 !important; background: transparent !important;
  }
  .ts-mobile-card-table > thead {
    position: absolute !important; width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important; border: 0 !important;
    overflow: hidden !important; clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
  }
  .ts-mobile-card-table > tbody { display: grid !important; gap: 12px !important; }
  .ts-mobile-card-table > tbody > tr {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px; min-width: 0; background: #fff !important;
    border: 1px solid #dae5f1 !important; border-radius: 13px !important;
    box-shadow: 0 2px 9px rgba(15,23,42,.05) !important;
    padding: 7px 13px !important; overflow: visible;
  }
  .ts-mobile-card-table > tbody > tr > td,
  .ts-mobile-card-table > tbody > tr > th {
    display: flex !important; flex-direction: column !important;
    gap: 3px; align-items: flex-start; justify-content: flex-start;
    padding: 9px 0 !important; min-width: 0 !important;
    border: 0 !important; text-align: left !important;
    white-space: normal !important; font-size: .8rem !important;
  }
  .ts-mobile-card-table > tbody > tr > td[data-ts-label]::before,
  .ts-mobile-card-table > tbody > tr > th[data-ts-label]::before {
    content: attr(data-ts-label); display: block;
    color: #647994; font-size: .67rem; font-weight: 750;
    text-transform: uppercase; letter-spacing: .025em; line-height: 1.3;
  }
  .ts-mobile-card-table > tbody > tr > :first-child.ts-data-primary {
    grid-column: 1 / -1; padding-bottom: 12px !important;
    border-bottom: 1px solid #e5edf7 !important; font-size: .91rem !important;
  }
  .ts-mobile-card-table > tbody > tr > :first-child.ts-data-primary::before { color: #4972a7; }
  .ts-mobile-card-table > tbody > tr > .ts-data-actions-cell {
    grid-column: 1 / -1; border-top: 1px solid #e5edf7 !important;
    margin-top: 4px; padding: 10px 0 5px !important;
  }
  .ts-mobile-card-table .ts-data-actions-cell::before { display: none !important; }
  .ts-mobile-card-table .ts-table-actions { display: block; width: 100%; }
  .ts-mobile-card-table .ts-table-actions > summary {
    width: 100%; min-height: 44px; border-color: #bad2f1;
    justify-content: center; background: #f6faff; color: #1d4ed8;
  }
  .ts-mobile-card-table > tbody > tr > .ts-hide-mobile-designation,
  .ts-mobile-scroll-table .ts-hide-mobile-designation { display: none !important; }
  .ts-mobile-card-table > tbody > tr.ts-table-empty-row { display: block !important; padding: 18px !important; }
  .ts-mobile-card-table .ts-table-empty-row > td { display: block !important; text-align: center !important; }
  .ts-mobile-scroll-table { min-width: 620px !important; }
  .ts-data-table-wrap:has(.ts-mobile-scroll-table) { overflow-x: auto !important; }
  .ts-data-table:not(.ts-mobile-card-table) > thead > tr > .ts-hide-mobile-designation,
  .ts-data-table:not(.ts-mobile-card-table) > tbody > tr > .ts-hide-mobile-designation { display: none !important; }
}
@media (max-width: 370px) {
  .ts-mobile-card-table > tbody > tr { gap: 0 10px; padding: 6px 10px !important; }
  .ts-table-actions-menu { max-height: calc(100dvh - 20px); }
}
@media print {
  .ts-data-table-wrap { overflow: visible !important; }
  .ts-data-table { display: table !important; border-collapse: collapse !important; }
  .ts-data-table > thead { display: table-header-group !important; position: static !important; width: auto !important; height: auto !important; }
  .ts-data-table > tbody { display: table-row-group !important; }
  .ts-data-table > tbody > tr { display: table-row !important; border: 0 !important; box-shadow: none !important; }
  .ts-data-table > tbody > tr > td { display: table-cell !important; border: 1px solid #ccd5e0 !important; }
  .ts-data-table tbody td::before { display: none !important; }
  .ts-data-table .ts-hide-mobile-designation { display: table-cell !important; }
  .ts-table-actions, .ts-data-actions-cell { display: none !important; }
}
/* Self-contained sizing even in standalone administration pages. */
.ts-data-table .ts-table-actions,
.ts-data-table .ts-table-actions > summary,
.ts-data-table .ts-table-actions-menu,
.ts-data-table .ts-table-actions-menu > button,
.ts-data-table .ts-data-actions-cell { box-sizing: border-box !important; }
@media (max-width: 720px) {
  .ts-mobile-card-table .ts-data-actions-cell { width: 100%; }
  .ts-mobile-card-table .ts-table-actions { max-width: 100%; }
  .ts-data-table-wrap:has(.ts-mobile-scroll-table)::before {
    content: 'Swipe horizontally to view the full table →';
    display: block; padding: 8px 10px; color: #607996;
    background: #f7faff; font-size: .73rem; font-weight: 650;
  }
}
@media print {
  .ts-data-table-wrap:has(.ts-mobile-scroll-table)::before { display: none !important; }
}
