/* Salesmen Stock — independent from Customers */
.salesmen-stock-panel,
.salesmen-detail-panel {
  overflow: hidden;
  border: 1px solid #dce3ea;
  background: radial-gradient(circle at 100% 0, rgba(24, 108, 215, .045), transparent 34%), #fff;
}

.salesmen-page-head,
.salesmen-detail-head {
  align-items: flex-start;
  gap: 22px;
  padding: 22px 24px;
  border-bottom: 1px solid #e4e9ee;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 68%, #fff3f3 100%);
}

.salesmen-page-head h2,
.salesmen-detail-head h2 {
  margin-bottom: 4px;
  font-size: clamp(22px, 2vw, 30px);
}

.salesmen-page-head .section-subtitle,
.salesmen-detail-head .section-subtitle,
.salesmen-modal-card .section-subtitle,
.salesmen-wide-modal-card .section-subtitle,
.salesmen-sale-modal-card .section-subtitle {
  margin: 0;
  color: #667085;
  font-size: 13px;
}

.salesmen-page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.salesmen-page-actions button {
  min-height: 42px;
  white-space: nowrap;
}

.salesmen-page-actions .salesmen-give-button {
  border: 1px solid #075e58 !important;
  background: linear-gradient(135deg, #0f766e, #075e58) !important;
  color: #fff !important;
  box-shadow: 0 9px 20px rgba(15, 118, 110, .22) !important;
}

.salesmen-page-actions .salesmen-payment-button {
  border: 1px solid #1748a3 !important;
  background: linear-gradient(135deg, #2563eb, #1748a3) !important;
  color: #fff !important;
  box-shadow: 0 9px 20px rgba(37, 99, 235, .22) !important;
}

.salesmen-page-actions .salesmen-return-button {
  border: 1px solid #92400e !important;
  background: linear-gradient(135deg, #d97706, #92400e) !important;
  color: #fff !important;
  box-shadow: 0 9px 20px rgba(146, 64, 14, .22) !important;
}

.salesmen-page-actions .salesmen-sale-button {
  border-color: #c30000 !important;
  background: linear-gradient(135deg, #186CD7, #05388E) !important;
  color: #fff !important;
  box-shadow: 0 9px 20px rgba(193, 0, 0, .18);
}

.salesmen-page-actions .salesmen-add-button {
  border: 1px solid #05388E !important;
  background: linear-gradient(135deg, #186CD7, #05388E) !important;
  color: #fff !important;
}

.salesmen-page-actions button > span,
.salesmen-page-actions button > svg,
.salesmen-page-actions button > i,
.salesmen-page-actions button * {
  color: inherit !important;
  stroke: currentColor !important;
  opacity: 1 !important;
}

.salesmen-page-actions button:hover {
  color: #fff !important;
  filter: brightness(1.1);
}

.salesmen-page-actions button:disabled {
  border-color: #94a3b8 !important;
  background: #dbe3ec !important;
  color: #334155 !important;
  box-shadow: none !important;
  opacity: 1 !important;
}

.salesmen-total-grid,
.salesmen-detail-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px;
  background: #f7f9fb;
}

.salesmen-detail-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.salesmen-total-card {
  position: relative;
  min-width: 0;
  min-height: 126px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid #dfe5eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .055);
}

.salesmen-total-card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -35px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(37, 99, 235, .06);
}

.salesmen-total-card span {
  position: relative;
  z-index: 1;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.salesmen-total-card strong {
  position: relative;
  z-index: 1;
  color: #17202a;
  font-size: clamp(20px, 2vw, 29px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.salesmen-total-card small {
  position: relative;
  z-index: 1;
  color: #87909d;
  font-size: 11px;
}

.salesmen-total-card.total-salesmen { border-top: 4px solid #2563eb; }
.salesmen-total-card.total-qty { border-top: 4px solid #7c3aed; }
.salesmen-total-card.total-stock-value { border-top: 4px solid #0f766e; }
.salesmen-total-card.total-dues {
  border-top: 4px solid #186CD7;
  background: linear-gradient(145deg, #fff, #fff4f4);
}
.salesmen-total-card.total-on-us {
  border-top: 4px solid #d18b00;
  background: linear-gradient(145deg, #fff, #fff9eb);
}

.salesmen-list-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  border-top: 1px solid #e4e9ee;
  border-bottom: 1px solid #e4e9ee;
  background: #fff;
}

.salesmen-list-toolbar > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.salesmen-list-toolbar strong { font-size: 17px; }
.salesmen-list-toolbar span { color: #75808e; font-size: 12px; }
.salesmen-list-toolbar .inline-search { width: min(330px, 100%); }

.salesmen-main-table th {
  padding-top: 14px;
  padding-bottom: 14px;
  background: #f1f4f7;
  color: #344054;
  font-size: 11px;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.salesmen-main-table td {
  padding-top: 14px;
  padding-bottom: 14px;
  vertical-align: middle;
}

.salesman-name-link {
  color: #111827 !important;
  font-size: 15px;
  font-weight: 800 !important;
}

.table-secondary {
  display: block;
  margin-top: 4px;
  color: #8a94a3;
  font-size: 11px;
}

.due-amount { color: #c10000; font-weight: 800; }
.on-us-amount { color: #9a6700; font-weight: 800; }

.salesman-source-tag {
  display: inline-flex;
  margin-left: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff0f0;
  color: #0B4AA6;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.salesman-detail-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.salesman-detail-title-wrap > .mini-button { flex: 0 0 auto; margin-top: 1px; }
.salesman-held-section,
.salesman-history-section { padding: 0 20px 20px; }
.salesman-history-section { padding-top: 4px; }

.section-row-title {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-row-title h3 { margin: 0; font-size: 16px; }
.section-row-title span { color: #7b8490; font-size: 12px; }

.salesman-held-table th,
.salesman-history-table th {
  background: #f4f6f8;
  color: #475467;
  font-size: 11px;
  white-space: nowrap;
}

.salesman-history-wrap { max-height: 530px; }

.salesman-running-balance {
  min-width: 112px;
  color: #111827;
  font-weight: 800 !important;
  white-space: normal;
}

.salesman-running-balance.balance-due { color: #b42318; }
.salesman-running-balance.balance-credit { color: #9a6700; }
.salesman-running-balance.balance-clear { color: #067647; }

.salesman-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 10px;
  font-weight: 800;
}

.salesman-status.cash,
.salesman-status.received,
.salesman-status.completed { background: #e9f8f1; color: #067647; }
.salesman-status.due { background: #fff0f0; color: #c30000; }
.salesman-status.held { background: #eef4ff; color: #245db7; }

.salesmen-modal-card { width: min(560px, calc(100vw - 28px)); }
.salesmen-wide-modal-card {
  width: min(1120px, calc(100vw - 28px));
  max-height: min(90vh, 900px);
  overflow-y: auto;
}
.salesmen-sale-modal-card {
  width: min(980px, calc(100vw - 28px));
  max-height: min(90vh, 880px);
  overflow-y: auto;
}

.salesman-return-modal-card {
  width: min(1020px, calc(100vw - 28px));
}

.salesman-return-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #b7e4cf;
  border-left: 4px solid #067647;
  border-radius: 9px;
  background: #ecfdf3;
  color: #085d3a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
}

.salesman-return-notice svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-top: 1px;
}

.salesman-return-products {
  overflow: hidden;
  border: 1px solid #dde4eb;
  border-radius: 11px;
  background: #f8fafc;
}

.salesman-return-products .section-row-title {
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}

.salesman-return-table-wrap {
  max-height: min(42vh, 390px);
  overflow: auto;
}

.salesman-return-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef2f6;
  color: #475467;
  font-size: 10px;
  letter-spacing: .035em;
  text-transform: uppercase;
  white-space: nowrap;
}

.salesman-return-table td {
  vertical-align: middle;
}

.salesman-return-check-column,
.salesman-return-table td:first-child {
  width: 74px;
  min-width: 74px;
  text-align: center;
}

.salesman-return-select {
  width: 20px;
  height: 20px;
  accent-color: #d97706;
  cursor: pointer;
}

.salesman-return-row-selected td {
  background: #fff8eb;
}

.salesman-return-submit {
  border-color: #92400e !important;
  background: linear-gradient(135deg, #d97706, #92400e) !important;
  color: #fff !important;
}

.salesmen-form-grid { display: grid; gap: 12px; }
.salesmen-form-grid.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.salesmen-form-grid.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.salesmen-form-grid.four-column { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.salesman-product-lines {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #dde4eb;
  border-radius: 10px;
  background: #f8fafc;
}

.salesman-product-line-head,
.salesman-product-line {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) minmax(90px, .65fr) minmax(105px, .7fr) minmax(150px, 1fr) minmax(95px, .55fr) 42px;
  align-items: end;
  gap: 9px;
}

.salesman-product-line-head {
  padding: 0 4px;
  color: #667085;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.salesman-product-line {
  padding: 10px;
  border: 1px solid #e0e5eb;
  border-radius: 8px;
  background: #fff;
}

.salesman-product-line label { gap: 4px; }
.salesman-product-line.stock-warning { border-color: #186CD7; background: #f4f8ff; }
.mobile-line-label { display: none; }
.add-another-product { justify-self: start; }

.salesman-money-grid {
  padding: 12px;
  border: 1px solid #f0caca;
  border-radius: 9px;
  background: #fff8f8;
}

.salesman-exchange-rate-label { color: #05388E !important; font-weight: 800 !important; }
.salesman-exchange-rate-label input {
  border-color: #186CD7 !important;
  background: #fff !important;
  color: #111 !important;
}

.salesman-calculation-note {
  margin: 0;
  padding: 10px 12px;
  border-left: 4px solid #186CD7;
  border-radius: 5px;
  background: #fff4f4;
  color: #6b3333;
  font-size: 12px;
  line-height: 1.5;
}

.danger-mini,
.danger-action { color: #0B4AA6 !important; }

@media (max-width: 1180px) {
  .salesmen-total-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .salesmen-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .salesmen-page-head,
  .salesmen-detail-head { flex-direction: column; }
  .salesmen-page-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .salesmen-page-head,
  .salesmen-detail-head { padding: 17px 15px; }
  .salesmen-page-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
  .salesmen-page-actions button { width: 100%; }
  .salesmen-total-grid,
  .salesmen-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    padding: 12px;
  }
  .salesmen-total-card { min-height: 110px; padding: 13px; }
  .salesmen-total-card strong { font-size: 18px; }
  .salesmen-list-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 14px;
  }
  .salesmen-list-toolbar > div { justify-content: space-between; }
  .salesmen-list-toolbar .inline-search { width: 100%; }
  .salesmen-form-grid.two-column,
  .salesmen-form-grid.three-column,
  .salesmen-form-grid.four-column { grid-template-columns: 1fr; }
  .salesman-product-line-head { display: none; }
  .salesman-product-line {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }
  .salesman-product-line label:first-of-type,
  .salesman-product-line label:nth-of-type(4) { grid-column: 1 / -1; }
  .mobile-line-label { display: inline; color: #667085; font-size: 10px; }
  .salesman-held-section,
  .salesman-history-section { padding-right: 12px; padding-left: 12px; }
}

@media (max-width: 430px) {
  .salesmen-total-grid,
  .salesmen-detail-grid { grid-template-columns: 1fr; }
  .salesman-product-line { grid-template-columns: 1fr; }
  .salesman-product-line label { grid-column: 1 !important; }
}

/* Shared long-table usability: scrollbars, search focus, and pinned actions. */
.managed-table-scroll {
  position: relative;
  width: 100% !important;
  max-height: min(62dvh, 680px);
  overflow: auto !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #9aa4b2 #eef1f4;
  -webkit-overflow-scrolling: touch;
}

.managed-table-scroll-compact {
  max-height: min(44dvh, 390px);
}

.managed-table-scroll::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

.managed-table-scroll::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #eef1f4;
}

.managed-table-scroll::-webkit-scrollbar-thumb {
  border: 2px solid #eef1f4;
  border-radius: 999px;
  background: #9aa4b2;
}

.managed-table-scroll::-webkit-scrollbar-thumb:hover {
  background: #6f7a88;
}

#view-purchases .purchase-table-wrap,
#view-sales .sales-table-wrap,
#view-stock .stock-table-wrap,
#view-salesmen .salesmen-table-wrap,
#view-salesman-detail .salesman-history-wrap,
#view-returns .managed-table-scroll,
#view-expenses .managed-table-scroll,
#view-transactions .roz-namcha-table-panel > .managed-table-scroll {
  min-height: 230px;
  max-height: calc(100dvh - 300px) !important;
}

.managed-table-scroll table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 3 !important;
}

.sticky-actions-table {
  --action-column-width: 160px;
}

.sticky-actions-table thead th:last-child,
.sticky-actions-table tbody td:last-child {
  position: sticky !important;
  right: 0 !important;
  width: var(--action-column-width) !important;
  min-width: var(--action-column-width) !important;
  max-width: var(--action-column-width) !important;
  white-space: nowrap !important;
}

.sticky-actions-table thead th:last-child {
  z-index: 6 !important;
  background: #eef1f4 !important;
  box-shadow: -8px 0 14px -13px rgba(15, 23, 42, .75);
}

.sticky-actions-table tbody td:last-child {
  z-index: 2 !important;
  overflow: visible !important;
  background: #ffffff !important;
  box-shadow: -8px 0 14px -13px rgba(15, 23, 42, .55);
}

.sticky-actions-table tbody tr:nth-child(even) td:last-child {
  background: #fafbfc !important;
}

.sticky-actions-table tbody tr:hover td:last-child {
  background: #fff5f5 !important;
}

.sticky-actions-table .action-buttons {
  width: max-content !important;
  min-width: max-content !important;
  display: inline-flex !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  gap: 6px !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.sticky-actions-table .action-buttons > span:not(.hidden) {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.sticky-actions-table .row-action,
.sticky-actions-table .whatsapp-action,
.sticky-actions-table button[data-sale-action="pdf"] {
  flex: 0 0 auto !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.search-match-row td {
  background: #fff0f1 !important;
  color: #111827 !important;
}

.search-match-row td:first-child {
  box-shadow: inset 4px 0 0 #186CD7 !important;
}

.search-match-row td:not(:first-child) {
  box-shadow: none !important;
}

.sticky-actions-table .search-match-row td:last-child,
.sticky-actions-table tbody tr.search-match-row:nth-child(even) td:last-child {
  background: #fff0f1 !important;
  box-shadow: -8px 0 14px -13px rgba(15, 23, 42, .55) !important;
}

.salesmen-pdf-button {
  border: 1px solid #0369a1 !important;
  background: linear-gradient(135deg, #0ea5e9, #0369a1) !important;
  color: #ffffff !important;
  box-shadow: 0 9px 20px rgba(3, 105, 161, .20) !important;
}

.salesmen-pdf-button *,
.salesmen-pdf-button svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

@media (max-width: 767px) {
  .managed-table-scroll {
    max-height: 58dvh;
  }

  #view-purchases .purchase-table-wrap,
  #view-sales .sales-table-wrap,
  #view-stock .stock-table-wrap,
  #view-salesmen .salesmen-table-wrap,
  #view-salesman-detail .salesman-history-wrap,
  #view-returns .managed-table-scroll,
  #view-expenses .managed-table-scroll {
    min-height: 180px;
    max-height: 62dvh !important;
  }

  .sticky-actions-table thead th:last-child,
  .sticky-actions-table tbody td:last-child {
    width: var(--action-column-width) !important;
    min-width: var(--action-column-width) !important;
  }

  body[data-active-view="customer-sheet"] .sticky-actions-table tbody td:last-child,
  body[data-active-view="people"] .sticky-actions-table tbody td:last-child {
    position: static !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    box-shadow: none !important;
  }
}
