.history-item {
  background: var(--card-bg);
  padding: 18px;
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
  transition: all var(--transition);
}

.history-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
}

.history-item[data-type="purchase"] {
  border-left-color: var(--purchase-color);
}

.history-item[data-type="sale"] {
  border-left-color: var(--sale-color);
}

.history-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.history-date {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
}

.history-summary {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.history-labor {
  font-size: 14px;
  color: var(--warning-dark);
  margin: 8px 0;
  font-weight: 600;
}

.history-payment {
  font-size: 14px;
  margin: 8px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.payment-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
}

.payment-online {
  background: var(--info-light);
  color: var(--info-dark);
}

.payment-cash {
  background: var(--success-light);
  color: var(--success-dark);
}

.payment-due {
  background: var(--warning-light);
  color: var(--warning-dark);
}

.history-items-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--border-color);
}

.history-item-detail {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  line-height: 1.6;
}

.history-item-detail:last-child {
  border-bottom: none;
}

.history-item-detail strong {
  color: var(--text-primary);
  font-size: 15px;
}

.history-item-detail small {
  color: var(--text-secondary);
  display: block;
  margin-top: 4px;
  line-height: 1.5;
}

/* ==================== OLDER HISTORY (windowed loading) ==================== */
.infinite-scroll-sentinel {
  min-height: 1px;
  padding: 10px 0 16px;
  text-align: center;
  color: var(--text-secondary, #888);
  font-size: 13px;
}

.infinite-scroll-sentinel[data-state="idle"] {
  padding: 0;
}

.infinite-scroll-more,
.history-range-retry,
.history-search-older-btn {
  margin-left: 6px;
  padding: 6px 14px;
  border: 1px solid #6366f1;
  border-radius: 6px;
  background: white;
  color: #6366f1;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.history-search-older-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.history-search-footer {
  margin: 8px 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f5f5ff;
  color: #555;
  font-size: 13px;
  text-align: center;
}

.history-range-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 13px;
  font-weight: 500;
}

.history-range-notice.is-error {
  background: #fff3cd;
  color: #7a5a00;
}

.history-range-loading {
  opacity: 0.35;
  filter: blur(2px);
  transition: opacity 0.2s ease;
}

.history-range-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: historyRangeSpin 0.8s linear infinite;
}

@keyframes historyRangeSpin {
  to { transform: rotate(360deg); }
}

/* ==================== TYPE + DATE FILTERS (#160) ==================== */
.history-type-filter .filter-btn {
  min-width: 0;
  padding: 12px 6px;
}

.history-date-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.history-date-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #6b7280);
}

#historyDatePreset {
  flex: 1 1 180px;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
}

.history-custom-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 100%;
}

.history-custom-range[hidden],
.history-range-label[hidden] {
  display: none;
}

.history-custom-range input[type="date"] {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 10px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
}

.history-range-label {
  flex: 1 1 100%;
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
}

.history-apply-range {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: #6366f1;
  color: white;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.history-range-hint {
  flex: 1 1 100%;
  font-size: 13px;
  color: #b42318;
}

.history-range-hint[hidden] {
  display: none;
}

/* ==================== REPRINT / SHARE (#136) ==================== */
.bill-action-btn.btn-reprint {
  background: #0f766e;
  color: white;
}

.bill-action-btn.btn-reprint:hover {
  background: #115e59;
}

.bill-action-btn.btn-share {
  background: #25d366;
  color: #063;
}

.bill-action-btn.btn-share:hover {
  background: #1ebe57;
}

@media (max-width: 480px) {
  .history-apply-range {
    flex: 1 1 100%;
  }

  .bill-details-footer .bill-action-btn {
    padding: 10px 4px;
    font-size: 13px;
  }
}