.chart-container {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  min-height: 300px;
}

.chart-container canvas {
  max-width: 100%;
  height: auto !important;
}

/* -------------------- ITEM WISE REPORT -------------------- */
.item-report {
  background: var(--card-bg);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition: all var(--transition);
}

.item-report:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.item-report-header {
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.item-report-details {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* -------------------- ANIMATIONS -------------------- */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab.active {
  animation: fadeInUp 0.3s ease;
}

/* -------------------- UTILITIES -------------------- */
button, a, input[type="checkbox"] {
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html {
  scroll-behavior: smooth;
}

/* -------------------- MODE TOGGLE -------------------- */
.mode-toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  background: var(--light-bg);
  padding: 8px;
  border-radius: var(--radius-md);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-secondary);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.mode-btn:hover {
  color: var(--primary-color);
}

.mode-btn.active {
  background: var(--card-bg);
  color: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.mode-btn:active {
  transform: scale(0.98);
}

/* -------------------- MODE TOGGLE BUTTON -------------------- */
.mode-toggle-btn {
  background: linear-gradient(135deg, var(--sale-color), var(--sale-dark));
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

.mode-toggle-btn:hover {
  box-shadow: var(--shadow);
}

.mode-toggle-btn:active {
  transform: scale(0.95);
}

.mode-toggle-btn.sale-mode {
  background: linear-gradient(135deg, var(--purchase-color), var(--purchase-dark));
}

/* -------------------- MODAL POPUP -------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 450px;
  width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-header {
  background: var(--primary-gradient);
  color: white;
  padding: 14px 20px;
  text-align: center;
}

body:has(.tab.purchase-theme.active) .modal-overlay .modal-header {
  background: linear-gradient(135deg, var(--purchase-color), var(--purchase-dark));
}

body:has(.tab.sale-theme.active) .modal-overlay .modal-header {
  background: linear-gradient(135deg, var(--sale-color), var(--sale-dark));
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.modal-body {
  padding: 12px;
  text-align: left;
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  overflow-y: auto;
  flex: 1;
}

#modalMessage {
  margin: 0;
}

#modalMessage > div {
  text-align: left;
}

.modal-footer {
  padding: 16px 24px;
  background: var(--light-bg);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  min-width: 80px;
}

.modal-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.modal-btn:active {
  transform: scale(0.95);
}

.modal-btn-cancel {
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 2px solid var(--border-color);
}

.modal-btn-cancel:hover {
  background: var(--light-bg);
}

.modal-btn-confirm {
  background: var(--primary-gradient);
  color: white;
  box-shadow: var(--shadow-sm);
}

.modal-btn-confirm:hover {
  box-shadow: var(--shadow);
}

body:has(.tab.purchase-theme.active) .modal-btn-confirm {
  background: linear-gradient(135deg, var(--purchase-color), var(--purchase-dark));
}

body:has(.tab.purchase-theme.active) .modal-btn-confirm:hover {
  box-shadow: var(--shadow);
}

body:has(.tab.sale-theme.active) .modal-btn-confirm {
  background: linear-gradient(135deg, var(--sale-color), var(--sale-dark));
}

body:has(.tab.sale-theme.active) .modal-btn-confirm:hover {
  box-shadow: var(--shadow);
}

/* -------------------- ENHANCED TOUCH INTERACTIONS -------------------- */
button, .btn, input[type="submit"], input[type="button"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

button:active, .btn:active {
  transform: scale(0.98);
}

input, textarea, select {
  -webkit-tap-highlight-color: transparent;
  font-size: 16px; /* Prevents zoom on iOS */
}

/* Smooth scrolling for tabs */
.tab {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* Better focus states for accessibility */
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

/* Prevent pull-to-refresh on tabs with content */
.tab {
  overscroll-behavior-y: contain;
}

/* Payment checkbox styling */
.payment-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 6px;
  border: 2px solid var(--border-color);
  margin: 0;
  accent-color: var(--primary-color);
}

/* Enhanced dropdown arrow for rate input */
#billRate {
  position: relative;
  cursor: pointer;
}

#billRate::-webkit-calendar-picker-indicator {
  cursor: pointer;
  width: 24px;
  height: 24px;
  opacity: 0.7;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

#billRate::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

#billRate::-webkit-list-button {
  cursor: pointer;
  position: absolute;
}

/* Bill Details Overlay */
.bill-details-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  animation: fadeIn 0.2s ease;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bill-details-overlay.active {
  display: flex;
}

.bill-details-container {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.bill-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.bill-details-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--dark-color);
}

.bill-details-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.bill-details-close:hover {
  background: var(--bg-light);
  color: var(--dark-color);
}

.bill-details-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.bill-details-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  background: #f8f9fa;
}

.bill-action-btn {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-width: 0;
}

.bill-action-btn:active {
  transform: scale(0.98);
}

.bill-action-btn.btn-close {
  background: #6c757d;
  color: white;
}

.bill-action-btn.btn-close:hover {
  background: #5a6268;
}

.bill-action-btn.btn-delete {
  background: #dc3545;
  color: white;
}

.bill-action-btn.btn-delete:hover {
  background: #c82333;
}

.bill-action-btn.btn-edit {
  background: var(--primary-color);
  color: white;
}

.bill-action-btn.btn-edit:hover {
  background: #0056b3;
}

@media (max-width: 480px) {
  .bill-details-footer {
    gap: 6px;
    padding: 12px;
  }
  
  .bill-action-btn {
    padding: 10px 12px;
    font-size: 14px;
  }
}

.bill-info-section {
  margin-bottom: 24px;
}

.bill-info-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.bill-info-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 140px;
}

.bill-info-value {
  color: var(--dark-color);
  flex: 1;
}

.bill-items-table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.bill-items-table thead {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
}

.bill-items-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  font-size: 14px;
}

.bill-items-table th:not(:first-child) {
  text-align: right;
}

.bill-items-table tbody tr {
  border-bottom: 1px solid var(--border-color);
}

.bill-items-table tbody tr:last-child {
  border-bottom: none;
}

.bill-items-table td {
  padding: 12px;
  color: var(--dark-color);
}

.bill-items-table td:not(:first-child) {
  text-align: right;
}

.bill-totals-section {
  background: var(--bg-light);
  padding: 16px;
  border-radius: 8px;
  margin: 20px 0;
}

.bill-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 15px;
}

.bill-totals-row.total {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  border-top: 2px solid var(--border-color);
  padding-top: 10px;
  margin-top: 8px;
}

.bill-payment-section {
  background: #e7f3ff;
  padding: 16px;
  border-radius: 8px;
  margin: 20px 0;
}

.bill-payment-section h4 {
  margin: 0 0 12px 0;
  color: var(--primary-color);
  font-size: 16px;
}

.bill-payment-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: var(--dark-color);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
