/* ============================================================================
   INVOICES PAGE - G2 LOGISTICS CLIENT PORTAL
   Premium sidebar layout with G2 Design System
   ============================================================================ */

/* ============================================================================
   CSS VARIABLES - G2 Design System
   ============================================================================ */

:root {
  /* G2 Brand Colors - Orange Primary */
  --primary: #0A84DD;
  --primary-dark: #0070C2;
  --primary-darker: #CC4429;
  --primary-light: #3DA0EE;
  --primary-lighter: #FF9E85;
  --primary-glow: rgba(10, 132, 221, 0.15);
  --primary-subtle: rgba(10, 132, 221, 0.08);

  /* Warm Stone Neutrals */
  --stone-50: #FAFAF9;
  --stone-100: #F5F5F4;
  --stone-200: #E7E5E4;
  --stone-300: #D6D3D1;
  --stone-400: #A8A29E;
  --stone-500: #78716C;
  --stone-600: #57534E;
  --stone-700: #44403C;
  --stone-800: #292524;
  --stone-900: #1C1917;
  --stone-950: #0C0A09;

  /* Status Colors */
  --success: #059669;
  --success-light: #D1FAE5;
  --success-dark: #047857;

  --warning: #D97706;
  --warning-light: #FEF3C7;
  --warning-dark: #B45309;

  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --danger-dark: #B91C1C;

  --info: #0284C7;
  --info-light: #E0F2FE;

  /* Typography */
  --font-display: 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(28, 25, 23, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(28, 25, 23, 0.1);
  --shadow-card: 0 1px 3px rgba(28, 25, 23, 0.06), 0 4px 12px rgba(28, 25, 23, 0.04);
  --shadow-card-hover: 0 8px 30px rgba(28, 25, 23, 0.12);
  --shadow-orange: 0 10px 40px -10px rgba(10, 132, 221, 0.3);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --sidebar-width: 280px;
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--stone-100);
  color: var(--stone-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* Skip Link for Accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  transition: top var(--transition-base);
}

.skip-link:focus {
  top: 0;
}

/* ============================================================================
   APP LAYOUT - SIDEBAR + MAIN CONTENT
   ============================================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================================
   INVOICES CONTENT
   ============================================================================ */

.invoices-content {
  flex: 1;
  padding: var(--spacing-xl);
}

/* ============================================================================
   FILTERS CARD
   ============================================================================ */

.filters-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  gap: var(--spacing-md);
  align-items: center;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 280px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--stone-400);
  stroke-width: 2;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--stone-900);
  background: var(--stone-50);
  transition: all var(--transition-base);
}

.search-input::placeholder {
  color: var(--stone-400);
}

.search-input:hover {
  border-color: var(--stone-400);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filters-row {
  display: flex;
  gap: var(--spacing-sm);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-base);
  border: none;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(10, 132, 221, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
  transform: translateY(-1px);
  box-shadow: var(--shadow-orange);
}

.btn-secondary {
  background: white;
  color: var(--stone-700);
  border: 1px solid var(--stone-300);
}

.btn-secondary:hover {
  background: var(--stone-50);
  border-color: var(--stone-400);
}

.btn-light {
  background: var(--stone-100);
  color: var(--stone-700);
  border: 1px solid var(--stone-200);
}

.btn-light:hover {
  background: var(--stone-200);
  border-color: var(--stone-300);
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  gap: var(--spacing-md);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--stone-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state p {
  font-size: 14px;
  color: var(--stone-500);
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */

.empty-state {
  text-align: center;
  padding: var(--spacing-2xl);
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--spacing-lg);
  background: var(--primary-subtle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 36px;
  height: 36px;
  color: var(--primary);
  stroke-width: 1.5;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--stone-900);
  margin-bottom: var(--spacing-sm);
}

.empty-state p {
  font-size: 14px;
  color: var(--stone-500);
}

/* ============================================================================
   GLOBAL SVG SIZING - Prevent massive icons
   ============================================================================ */

svg {
  flex-shrink: 0;
}

/* ============================================================================
   INVOICES LIST
   ============================================================================ */

.invoices-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

/* ============================================================================
   INVOICE LIST ITEMS (from invoices-list-modal.js)
   ============================================================================ */

.invoice-list-item {
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: stretch;
  cursor: pointer;
  transition: all var(--transition-slow);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  animation: cardFadeIn 0.4s ease-out both;
}

.invoice-list-item:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  border-color: var(--stone-300);
}

.invoice-list-status {
  width: 4px;
  flex-shrink: 0;
}

.invoice-list-status.paid { background: var(--success); }
.invoice-list-status.outstanding { background: var(--warning); }
.invoice-list-status.overdue { background: var(--danger); }

.invoice-list-content {
  flex: 1;
  padding: var(--spacing-md) var(--spacing-lg);
  min-width: 0;
}

.invoice-list-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.invoice-list-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--stone-900);
  margin: 0 0 4px 0;
}

.invoice-list-reference {
  font-size: 13px;
  color: var(--stone-500);
  margin: 0;
}

.invoice-list-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.invoice-list-badge.paid { background: var(--success-light); color: var(--success); }
.invoice-list-badge.outstanding { background: var(--warning-light); color: var(--warning-dark); }
.invoice-list-badge.overdue { background: var(--danger-light); color: var(--danger); }

.invoice-list-info {
  display: flex;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
}

.invoice-list-info-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--stone-500);
}

.invoice-list-info-item svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
  flex-shrink: 0;
  color: var(--stone-400);
}

.invoice-list-amount {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-left: 1px solid var(--stone-200);
  min-width: 120px;
}

.invoice-list-total {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--stone-900);
}

.invoice-list-vat-label {
  font-size: 11px;
  color: var(--stone-400);
  text-transform: uppercase;
}

.invoice-list-due {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
  margin-top: 4px;
}

.invoice-list-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--spacing-md);
  color: var(--stone-400);
  border-left: 1px solid var(--stone-200);
  transition: color var(--transition-fast);
}

.invoice-list-item:hover .invoice-list-arrow {
  color: var(--primary);
}

.invoice-list-arrow svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* ============================================================================
   INVOICE CARD
   ============================================================================ */

.invoice-card {
  background: white;
  border: 1px solid var(--stone-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-slow);
  overflow: hidden;
  animation: cardFadeIn 0.4s ease-out both;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.invoice-card:nth-child(1) { animation-delay: 0ms; }
.invoice-card:nth-child(2) { animation-delay: 50ms; }
.invoice-card:nth-child(3) { animation-delay: 100ms; }
.invoice-card:nth-child(4) { animation-delay: 150ms; }
.invoice-card:nth-child(5) { animation-delay: 200ms; }

.invoice-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  border-color: var(--stone-300);
}

/* Invoice Header */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--stone-100);
  background: linear-gradient(180deg, var(--stone-50) 0%, white 100%);
}

.invoice-title {
  display: flex;
  gap: var(--spacing-md);
  align-items: flex-start;
}

.invoice-icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
  stroke-width: 1.75;
  flex-shrink: 0;
}

.invoice-number {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--stone-900);
  margin-bottom: 4px;
}

.invoice-reference {
  font-size: 13px;
  color: var(--stone-500);
  font-weight: 500;
}

/* Status Badges */
.invoice-status-badge {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-paid {
  background: var(--success-light);
  color: var(--success-dark);
}

.status-pending,
.status-authorised,
.status-submitted {
  background: var(--primary-subtle);
  color: var(--primary-dark);
}

.status-draft {
  background: var(--stone-100);
  color: var(--stone-600);
}

.status-cancelled,
.status-voided {
  background: var(--danger-light);
  color: var(--danger-dark);
}

/* Invoice Body */
.invoice-body {
  padding: var(--spacing-lg);
}

.invoice-details {
  margin-bottom: var(--spacing-lg);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--stone-200);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 14px;
  color: var(--stone-500);
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--stone-800);
}

.detail-value.job-ref {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

/* Invoice Amounts */
.invoice-amounts {
  background: var(--stone-50);
  padding: var(--spacing-md);
  border-radius: var(--radius-lg);
  border: 1px solid var(--stone-200);
}

.amount-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  color: var(--stone-600);
}

.amount-row.total {
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-md);
  border-top: 2px solid var(--stone-300);
  font-size: 18px;
  font-weight: 700;
  color: var(--stone-900);
}

.amount-row.total span:last-child {
  color: var(--primary-dark);
}

/* Line Items */
.invoice-line-items {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--stone-200);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.invoice-line-items h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--stone-800);
  margin-bottom: var(--spacing-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

.invoice-line-items h4::before {
  content: '';
  width: 4px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
}

.line-items-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  font-size: 13px;
}

.line-items-table thead {
  background: var(--stone-100);
}

.line-items-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--stone-700);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.line-items-table td {
  padding: 10px 12px;
  color: var(--stone-600);
  border-bottom: 1px solid var(--stone-100);
}

.line-items-table tbody tr:last-child td {
  border-bottom: none;
}

.line-items-table tbody tr:hover {
  background: var(--stone-50);
}

/* Invoice Footer */
.invoice-footer {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--stone-200);
  background: var(--stone-50);
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-md);
  background: white;
  color: var(--stone-700);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-base);
  font-family: var(--font-body);
}

.btn-action:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

.btn-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-action svg {
  width: 16px;
  height: 16px;
}

.btn-action.view-xero,
.btn-action.download-pdf.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-color: var(--primary);
}

.btn-action.view-xero:hover:not(:disabled),
.btn-action.download-pdf.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
  color: white;
  transform: translateY(-1px);
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  background: white;
  border-radius: var(--radius-2xl);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

.modal-panel.large {
  max-width: 800px;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--stone-200);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--stone-900);
}

.modal-subtitle {
  font-size: 14px;
  color: var(--stone-500);
  margin-top: 4px;
}

.modal-close {
  width: 36px;
  height: 36px;
  background: var(--stone-100);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
}

.modal-close:hover {
  background: var(--stone-200);
}

.modal-close svg {
  width: 18px;
  height: 18px;
  color: var(--stone-600);
  stroke-width: 2;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

/* Modal Content SVG Sizing */
.modal-body svg:not([style*="width"]) {
  width: 18px;
  height: 18px;
}

/* Detail Sections (used in modals) */
.detail-section {
  margin-bottom: var(--spacing-lg);
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid var(--stone-100);
}

.detail-section-header svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
  stroke-width: 2;
  flex-shrink: 0;
}

.detail-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--stone-800);
}

.detail-grid {
  display: grid;
  gap: var(--spacing-sm);
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--stone-200);
  background: var(--stone-50);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

.modal-ref {
  font-size: 13px;
  color: var(--stone-500);
  font-family: var(--font-mono);
}

/* ============================================================================
   RESPONSIVE - MOBILE
   ============================================================================ */

@media (max-width: 768px) {
  /* Invoices Content Mobile */
  .invoices-content {
    padding: var(--spacing-md);
  }

  .filters-card {
    flex-direction: column;
    padding: var(--spacing-md);
  }

  .search-box {
    min-width: 100%;
  }

  .filters-row {
    width: 100%;
  }

  .filters-row .btn {
    flex: 1;
  }

  /* Invoice Card Mobile */
  .invoice-header {
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
  }

  .invoice-body {
    padding: var(--spacing-md);
  }

  .invoice-footer {
    flex-direction: column;
    padding: var(--spacing-md);
  }

  .btn-action {
    width: 100%;
  }

  /* Modal Mobile */
  .modal-panel {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-md);
  }

  .modal-footer {
    flex-direction: column;
    gap: var(--spacing-md);
    border-radius: 0;
  }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

[hidden] {
  display: none !important;
}

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .filters-card,
  .invoice-footer,
  .btn-action {
    display: none !important;
  }

  .invoice-card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }
}

/* ============================================================================
   DARK MODE
   ============================================================================ */

[data-theme="dark"] {
  /* Invert stone neutrals for dark mode */
  --stone-50: #1C1917;
  --stone-100: #292524;
  --stone-200: #44403C;
  --stone-300: #57534E;
  --stone-400: #78716C;
  --stone-500: #A8A29E;
  --stone-600: #D6D3D1;
  --stone-700: #E7E5E4;
  --stone-800: #F5F5F4;
  --stone-900: #FAFAF9;

  /* Dark mode shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.3);

  /* Status light backgrounds for dark mode */
  --success-light: rgba(5, 150, 105, 0.15);
  --warning-light: rgba(217, 119, 6, 0.15);
  --danger-light: rgba(220, 38, 38, 0.15);
  --info-light: rgba(2, 132, 199, 0.15);
}

/* --- Base --- */
[data-theme="dark"] body {
  background: #2D2D2B;
}

[data-theme="dark"] .invoices-content {
  background: #2D2D2B;
}

/* --- Filters Card --- */
[data-theme="dark"] .filters-card {
  background: #353533;
  border-color: #454543;
}

[data-theme="dark"] .filters-card label {
  color: #B0B0B0;
}

[data-theme="dark"] .filter-input,
[data-theme="dark"] .filter-select {
  background: #3D3D3B;
  border-color: #454543;
  color: #FFFFFF;
}

/* --- Search Input --- */
[data-theme="dark"] .search-input {
  background: #3D3D3B;
  border-color: #454543;
  color: #FAFAF9;
}

[data-theme="dark"] .search-input::placeholder {
  color: #78716C;
}

[data-theme="dark"] .search-input:hover {
  border-color: #57534E;
}

[data-theme="dark"] .search-input:focus {
  background: #3D3D3B;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 132, 221, 0.2);
}

/* --- Buttons --- */
[data-theme="dark"] .btn-light {
  background: #3D3D3B;
  border-color: #454543;
  color: #E7E5E4;
}

[data-theme="dark"] .btn-light:hover {
  background: #454543;
  border-color: #57534E;
  color: #FAFAF9;
}

[data-theme="dark"] .btn-secondary {
  background: #3D3D3B;
  border-color: #454543;
  color: #D6D3D1;
}

[data-theme="dark"] .btn-secondary:hover {
  background: #454543;
  color: #FAFAF9;
}

/* --- Invoice Card --- */
[data-theme="dark"] .invoice-card {
  background: #353533;
  border-color: #454543;
}

[data-theme="dark"] .invoice-card:hover {
  border-color: var(--primary);
}

[data-theme="dark"] .invoice-header {
  background: linear-gradient(180deg, #3D3D3B 0%, #353533 100%);
  border-bottom-color: #454543;
}

[data-theme="dark"] .invoice-number {
  color: #FAFAF9;
}

[data-theme="dark"] .invoice-reference {
  color: #A8A29E;
}

[data-theme="dark"] .invoice-date,
[data-theme="dark"] .invoice-meta {
  color: #78716C;
}

[data-theme="dark"] .invoice-amount {
  color: #FAFAF9;
}

[data-theme="dark"] .invoice-jobs {
  color: #A8A29E;
}

[data-theme="dark"] .invoice-amounts {
  background: #3D3D3B;
  border-color: #454543;
}

[data-theme="dark"] .amount-row {
  color: #D6D3D1;
}

[data-theme="dark"] .amount-row.total {
  color: #FAFAF9;
  border-top-color: #57534E;
}

[data-theme="dark"] .invoice-footer {
  background: #3D3D3B;
  border-top-color: #454543;
}

[data-theme="dark"] .btn-action {
  background: #353533;
  border-color: #454543;
  color: #D6D3D1;
}

[data-theme="dark"] .btn-action:hover:not(:disabled) {
  background: rgba(10, 132, 221, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

/* --- Invoice List Items --- */
[data-theme="dark"] .invoice-list-item {
  background: #353533;
  border-color: #454543;
}

[data-theme="dark"] .invoice-list-item:hover {
  border-color: #57534E;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .invoice-list-content {
  background: transparent;
}

[data-theme="dark"] .invoice-list-title {
  color: #FAFAF9;
}

[data-theme="dark"] .invoice-list-reference {
  color: #A8A29E;
}

[data-theme="dark"] .invoice-list-info-item {
  color: #A8A29E;
}

[data-theme="dark"] .invoice-list-info-item svg {
  color: #78716C;
}

[data-theme="dark"] .invoice-list-amount {
  border-left-color: #454543;
}

[data-theme="dark"] .invoice-list-total {
  color: #FAFAF9;
}

[data-theme="dark"] .invoice-list-vat-label {
  color: #78716C;
}

[data-theme="dark"] .invoice-list-arrow {
  color: #78716C;
  border-left-color: #454543;
}

[data-theme="dark"] .invoice-list-item:hover .invoice-list-arrow {
  color: var(--primary);
}

/* --- Status Badges (dark mode) --- */
[data-theme="dark"] .invoice-list-badge.paid {
  background: rgba(5, 150, 105, 0.15);
  color: #34D399;
}

[data-theme="dark"] .invoice-list-badge.outstanding {
  background: rgba(217, 119, 6, 0.15);
  color: #FBBF24;
}

[data-theme="dark"] .invoice-list-badge.overdue {
  background: rgba(220, 38, 38, 0.15);
  color: #F87171;
}

[data-theme="dark"] .invoice-status-badge {
  opacity: 0.95;
}

[data-theme="dark"] .status-paid {
  background: rgba(5, 150, 105, 0.15);
  color: #34D399;
}

[data-theme="dark"] .status-pending,
[data-theme="dark"] .status-authorised,
[data-theme="dark"] .status-submitted {
  background: rgba(10, 132, 221, 0.12);
  color: #3DA0EE;
}

[data-theme="dark"] .status-draft {
  background: #3D3D3B;
  color: #A8A29E;
}

[data-theme="dark"] .status-cancelled,
[data-theme="dark"] .status-voided {
  background: rgba(220, 38, 38, 0.15);
  color: #F87171;
}

[data-theme="dark"] .job-list-badge.paid {
  background: rgba(5, 150, 105, 0.15);
  color: #34D399;
}

[data-theme="dark"] .job-list-badge.outstanding {
  background: rgba(217, 119, 6, 0.15);
  color: #FBBF24;
}

[data-theme="dark"] .job-list-badge.overdue {
  background: rgba(220, 38, 38, 0.15);
  color: #F87171;
}

/* --- Modal --- */
[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-panel {
  background: #353533;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .modal-header {
  border-bottom-color: #454543;
}

[data-theme="dark"] .modal-header h3 {
  color: #FAFAF9;
}

[data-theme="dark"] .modal-subtitle {
  color: #A8A29E;
}

[data-theme="dark"] .modal-close {
  background: #3D3D3B;
}

[data-theme="dark"] .modal-close:hover {
  background: #454543;
}

[data-theme="dark"] .modal-close svg {
  color: #D6D3D1;
}

[data-theme="dark"] .modal-body {
  color: #D6D3D1;
}

[data-theme="dark"] .modal-footer {
  background: #3D3D3B;
  border-top-color: #454543;
}

[data-theme="dark"] .modal-ref {
  color: #A8A29E;
}

[data-theme="dark"] .modal-title {
  color: #FAFAF9;
}

[data-theme="dark"] .modal-content {
  background: #353533;
}

/* --- Detail Sections (inside modal) --- */
[data-theme="dark"] .detail-section {
  color: #D6D3D1;
}

[data-theme="dark"] .detail-section-header {
  border-bottom-color: #454543;
}

[data-theme="dark"] .detail-section-header svg {
  color: var(--primary);
}

[data-theme="dark"] .detail-section-title {
  color: #F5F5F4;
}

[data-theme="dark"] .detail-label {
  color: #A8A29E;
}

[data-theme="dark"] .detail-value {
  color: #F5F5F4;
}

[data-theme="dark"] .detail-value.job-ref {
  color: var(--primary);
  background: rgba(10, 132, 221, 0.1);
}

[data-theme="dark"] .detail-row {
  border-bottom-color: #454543;
}

[data-theme="dark"] .detail-grid {
  color: #D6D3D1;
}

/* Download section background in modal */
[data-theme="dark"] .detail-section div[style*="background: var(--gray-50)"],
[data-theme="dark"] .detail-section div[style*="background: var(--stone-50)"] {
  background: #3D3D3B !important;
}

/* --- Line Items Table --- */
[data-theme="dark"] .line-items-table thead {
  background: #3D3D3B;
}

[data-theme="dark"] .line-items-table th {
  color: #D6D3D1;
}

[data-theme="dark"] .line-items-table td {
  color: #A8A29E;
  border-bottom-color: #454543;
}

[data-theme="dark"] .line-items-table tbody tr:hover {
  background: #3D3D3B;
}

[data-theme="dark"] .invoice-line-items {
  border-top-color: #454543;
}

[data-theme="dark"] .invoice-line-items h4 {
  color: #F5F5F4;
}

/* --- Empty State --- */
[data-theme="dark"] .empty-state {
  background: #353533;
  border-color: #454543;
}

[data-theme="dark"] .empty-state h3 {
  color: #FAFAF9;
}

[data-theme="dark"] .empty-state p {
  color: #78716C;
}

[data-theme="dark"] .empty-icon {
  background: rgba(10, 132, 221, 0.1);
}

/* --- Loading State --- */
[data-theme="dark"] .loading-spinner {
  border-color: #454543;
  border-top-color: var(--primary);
}

[data-theme="dark"] .loading-state p {
  color: #A8A29E;
}

/* --- Stat Card Hover States --- */
[data-theme="dark"] .stat-card {
  background: #353533;
  border-color: #454543;
}

[data-theme="dark"] .stat-card:hover {
  border-color: #57534E;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

/* --- Scrollbar Styling --- */
[data-theme="dark"] .modal-body::-webkit-scrollbar {
  width: 6px;
}

[data-theme="dark"] .modal-body::-webkit-scrollbar-track {
  background: #292524;
  border-radius: 3px;
}

[data-theme="dark"] .modal-body::-webkit-scrollbar-thumb {
  background: #57534E;
  border-radius: 3px;
}

[data-theme="dark"] .modal-body::-webkit-scrollbar-thumb:hover {
  background: #78716C;
}

[data-theme="dark"] .invoices-list::-webkit-scrollbar {
  width: 6px;
}

[data-theme="dark"] .invoices-list::-webkit-scrollbar-track {
  background: #292524;
  border-radius: 3px;
}

[data-theme="dark"] .invoices-list::-webkit-scrollbar-thumb {
  background: #57534E;
  border-radius: 3px;
}

[data-theme="dark"] .invoices-list::-webkit-scrollbar-thumb:hover {
  background: #78716C;
}

/* --- Utility text colors in dark mode --- */
[data-theme="dark"] .text-primary {
  color: var(--primary) !important;
}

/* --- Modal button (primary) in dark mode --- */
[data-theme="dark"] .btn-modal.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

[data-theme="dark"] .btn-modal.primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
}
