/* ── Sales Ledger Page (green theme) ── */
.sales-ledger-page {
  --sl-accent: #16a34a;
  --sl-accent-soft: #f0fdf4;
  --sl-accent-border: #bbf7d0;
  --sl-accent-dark: #15803d;
  min-height: 100%;
}
.sl-header-row,
.sl-page-header {
  margin-bottom: var(--space-md);
}

.sl-stat-card[data-filter] {
  cursor: pointer;
}

.sl-stat-card[data-filter]:hover {
  border-color: var(--sl-accent);
}

/* ── Mobile List ── */
.sl-mobile-list {
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
}

.sl-mobile-list.is-visible {
  display: flex;
}

.sl-mobile-card {
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.sl-mobile-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.sl-mobile-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  margin-bottom: 4px;
}

.sl-mobile-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-bn);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.sl-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-left: 4px solid var(--sl-accent);
  padding-left: var(--space-sm);
}

.sl-title-wrap .page-title-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  transition: background 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.sl-title-wrap .page-title-back:hover {
  background: var(--sl-accent-soft);
  color: var(--sl-accent-dark);
}

.sl-title-wrap .page-title-back svg {
  width: 20px;
  height: 20px;
}

.sl-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sl-new-sell-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.toolbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-icon-btn:hover {
  border-color: var(--sl-accent);
  color: var(--sl-accent-dark);
  background: var(--sl-accent-soft);
}

.toolbar-icon-btn svg {
  width: 18px;
  height: 18px;
}

.toolbar-select {
  height: 42px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none;
  cursor: pointer;
  min-width: 140px;
}

.toolbar-select:focus {
  outline: none;
  border-color: var(--sl-accent);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

/* ── Stats Grid ── */
.sl-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.sl-stat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.sl-stat-card.is-total {
  border-top: 3px solid var(--sl-accent);
}

.sl-stat-card.is-due {
  border-top: 3px solid #e5e7eb;
}

.sl-stat-card.is-due.has-due {
  border-top-color: #dc2626;
}

.sl-stat-card.is-due.has-due .sl-stat-value {
  color: #dc2626;
}

.sl-stat-label {
  display: block;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.sl-stat-value {
  font-family: var(--font-en);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
}

.sl-stat-card.is-total .sl-stat-value {
  color: var(--sl-accent-dark);
}

.sl-stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--sl-accent-soft);
  color: var(--sl-accent-dark);
  flex-shrink: 0;
}

.sl-stat-icon svg {
  width: 22px;
  height: 22px;
}

.sl-stat-card.is-due .sl-stat-icon {
  background: #f3f4f6;
  color: var(--color-text-muted);
}

.sl-stat-card.is-due.has-due .sl-stat-icon {
  background: #fef2f2;
  color: #dc2626;
}

/* ── Toolbar ── */
.sl-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.sl-date-range {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  min-width: 200px;
}

.sl-date-range-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.sl-date-range-label {
  font-family: var(--font-en);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  white-space: nowrap;
}

.sl-date-range-inputs {
  position: absolute;
  inset: 0;
  opacity: 0;
  display: flex;
  pointer-events: none;
}

.sl-date-range-inputs input {
  flex: 1;
  width: 50%;
  height: 100%;
  cursor: pointer;
  pointer-events: auto;
}

.sl-search-wrap,
.sl-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 180px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.sl-search-wrap:focus-within,
.sl-search-box:focus-within {
  border-color: var(--sl-accent);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2);
}

.sl-search-wrap svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.sl-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background: transparent;
}

.sl-search-input::placeholder {
  color: var(--color-text-muted);
}

/* ── Table ── */
.sl-table-meta {
  margin: var(--space-md) 0 var(--space-sm);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.sl-table-meta strong {
  color: var(--color-text-primary);
}

.sl-table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.sl-table-scroll {
  overflow-x: auto;
}

.sl-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.sl-table thead {
  background: var(--sl-accent-soft);
}

.sl-table th {
  padding: 12px 14px;
  font-family: var(--font-bn);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--sl-accent-dark);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.sl-table td {
  padding: 12px 14px;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.sl-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.sl-table tbody tr:hover {
  background: var(--sl-accent-soft);
}

.sl-table tbody tr:last-child td {
  border-bottom: none;
}

.sl-invoice-badge {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--font-en);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--sl-accent-dark);
  background: var(--sl-accent-soft);
  border: 1px solid var(--sl-accent-border);
  border-radius: var(--radius-sm);
}

.sl-cell-money {
  font-family: var(--font-en);
  font-weight: 600;
  white-space: nowrap;
}

.sl-cell-due.has-due {
  color: #dc2626;
  font-weight: 700;
}

.sl-cell-items {
  font-family: var(--font-en);
  font-weight: 600;
}

.sl-payment-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-bn);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.sl-badge-cash {
  background: var(--sl-accent-soft);
  color: var(--sl-accent-dark);
  border: 1px solid var(--sl-accent-border);
}

.sl-badge-due {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.sl-badge-bank {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.sl-badge-card {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.sl-badge-bkash {
  background: #fdf2f8;
  color: #be185d;
  border: 1px solid #fbcfe8;
}

/* ── Empty State ── */
.sl-empty-state {
  display: none;
  text-align: center;
  padding: var(--space-xl);
}

.sl-empty-state.is-visible {
  display: block;
}

.sl-empty-subtext {
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 8px 0 var(--space-md);
}

.sl-empty-cta {
  display: inline-flex;
  text-decoration: none;
}

.sl-table-card.is-hidden {
  display: none;
}

/* ── Detail Drawer ── */
.sl-detail-panel .drawer-header {
  align-items: flex-start;
}

.sl-detail-invoice {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  font-family: var(--font-en);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--sl-accent-dark);
  background: var(--sl-accent-soft);
  border-radius: var(--radius-sm);
}

.sl-detail-meta {
  padding: var(--space-md);
  background: #fafafa;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.sl-detail-meta-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 6px 0;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
}

.sl-detail-meta-row + .sl-detail-meta-row {
  border-top: 1px dashed var(--color-border-light);
}

.sl-detail-label {
  color: var(--color-text-muted);
}

.sl-detail-value {
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: right;
}

.sl-detail-section-title {
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-sm);
}

.sl-detail-items-wrap {
  overflow-x: auto;
  margin-bottom: var(--space-md);
}

.sl-detail-items {
  width: 100%;
  border-collapse: collapse;
  min-width: 320px;
}

.sl-detail-items th,
.sl-detail-items td {
  padding: 8px 10px;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}

.sl-detail-items th {
  font-weight: 600;
  color: var(--color-text-muted);
  background: #fafafa;
}

.sl-detail-items td:nth-child(n+2) {
  font-family: var(--font-en);
  font-weight: 600;
}

.sl-detail-summary {
  padding: var(--space-md);
  background: var(--sl-accent-soft);
  border: 1px solid var(--sl-accent-border);
  border-radius: var(--radius-md);
}

.sl-detail-summary-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 6px 0;
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.sl-detail-summary-row span:last-child {
  font-family: var(--font-en);
  font-weight: 600;
  color: var(--color-text-primary);
}

.sl-detail-summary-total {
  font-weight: 700;
  border-top: 1px dashed var(--sl-accent-border);
  margin-top: 4px;
  padding-top: 10px;
}

.sl-detail-summary-total span:last-child {
  font-size: var(--text-md);
  color: var(--sl-accent-dark);
}

.sl-detail-due.has-due {
  color: #dc2626 !important;
}

/* ── Toast ── */
.sl-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 300;
  padding: 12px 20px;
  background: #111827;
  color: #fff;
  border-radius: var(--radius-md);
  font-family: var(--font-bn);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s ease;
  pointer-events: none;
}

.sl-toast.is-visible {
  transform: translateX(-50%) translateY(0);
}

.sl-toast.is-error {
  background: #991b1b;
}

/* ── Responsive ── */
@media (max-width: 992px) {
  .sl-stats-grid {
    grid-template-columns: 1fr;
  }

  .sl-table-card { display: none !important; }
  .sl-mobile-list.is-visible { display: flex; }
  .sl-search-box,
  .sl-date-range,
  .toolbar-select { min-width: 0; }
}

@media (max-width: 768px) {
  .sl-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-select,
  .sl-date-range,
  .sl-search-box {
    width: 100%;
    min-width: 0;
  }

  .sl-header-actions {
    width: 100%;
  }

  .sl-new-sell-link {
    flex: 1;
    justify-content: center;
  }

  .sl-table-card {
    display: none;
  }

  .sl-mobile-list.is-visible {
    display: flex;
  }
}
