/* Invoice Module Styles */

/* ============================================
   ACORDIÃO DE FACTURAÇÃO - ESTILOS MODERNOS
   ============================================ */

.invoice-accordion {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.accordion-section {
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-background, #ffffff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-section:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--background-color, #f8f9fa);
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
  border-bottom: 1px solid transparent;
}

.accordion-header:hover {
  background: var(--hover-background, #f0f2f5);
}

.accordion-header.active {
  background: linear-gradient(
    135deg,
    rgba(0, 126, 199, 0.08) 0%,
    rgba(0, 126, 199, 0.04) 100%
  );
  border-bottom-color: var(--border-color, #e0e0e0);
}

.accordion-header-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.accordion-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color, #007ec7);
  color: white;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 126, 199, 0.25);
  transition: all 0.3s ease;
}

.accordion-header:not(.active) .accordion-number {
  background: #ccc;
  color: #666;
  box-shadow: none;
}

.accordion-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #333);
  transition: color 0.3s ease;
}

.accordion-header:not(.active) h3 {
  color: var(--text-secondary, #666);
}

.accordion-icon {
  font-size: 18px;
  color: var(--text-secondary, #666);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-header.active .accordion-icon {
  transform: rotate(180deg);
  color: var(--primary-color, #007ec7);
}

.accordion-body {
  padding: 24px;
  background: var(--card-background, #ffffff);
  border-top: 1px solid var(--border-color, #e0e0e0);
  animation: accordionSlideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes accordionSlideDown {
  from {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  to {
    opacity: 1;
    max-height: 2000px;
    padding-top: 24px;
    padding-bottom: 24px;
  }
}

/* Leitura EAN / código de barras / QR (câmara) — factura e vendas a dinheiro */
.walaka-barcode-scan-section {
  margin-bottom: 1.25rem;
  padding: 1rem 1.125rem;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(0, 126, 199, 0.06) 0%,
    rgba(0, 126, 199, 0.02) 100%
  );
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.walaka-barcode-scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.walaka-barcode-scan-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.walaka-barcode-scan-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary, #333);
  letter-spacing: -0.01em;
}

.walaka-beta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0c4a6e;
  background: rgba(0, 126, 199, 0.18);
  border: 1px solid rgba(0, 126, 199, 0.35);
  border-radius: 999px;
  line-height: 1.2;
}

.walaka-barcode-scan-desc {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #666);
  line-height: 1.45;
}

.walaka-barcode-scan-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary, #555);
  margin-bottom: 0.35rem;
}

.walaka-barcode-scan-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.625rem;
}

.walaka-barcode-scan-input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 10px;
  font-size: 0.9rem;
  background: var(--card-background, #fff);
  color: var(--text-primary, #222);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.walaka-barcode-scan-input:focus {
  border-color: var(--primary-color, #007ec7);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 126, 199, 0.2);
}

.walaka-barcode-scan-input::placeholder {
  color: var(--text-secondary, #999);
}

.walaka-barcode-camera-btn {
  flex-shrink: 0;
  align-self: stretch;
  min-height: 2.75rem;
  padding-left: 1rem;
  padding-right: 1rem;
  border-radius: 10px;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.walaka-barcode-camera-btn:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

@media (max-width: 540px) {
  .walaka-barcode-scan-section {
    padding: 0.875rem 1rem;
  }

  .walaka-barcode-scan-row {
    flex-direction: column;
    align-items: stretch;
  }

  .walaka-barcode-camera-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Botões de Acção do Formulário */
.invoice-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 24px;
  background: var(--background-color, #f8f9fa);
  border-top: 1px solid var(--border-color, #e0e0e0);
  border-radius: 0 0 12px 12px;
  margin-top: 12px;
}

.invoice-form-actions .btn {
  min-width: 160px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

/* Dark Mode Support */
[data-theme="dark"] .accordion-section {
  background: #23262f;
  border-color: #2a2d3a;
}

[data-theme="dark"] .accordion-header {
  background: #2a2d3a;
  color: #e0e0e0;
}

[data-theme="dark"] .accordion-header:hover {
  background: #2f323d;
}

[data-theme="dark"] .accordion-header.active {
  background: linear-gradient(
    135deg,
    rgba(37, 99, 235, 0.15) 0%,
    rgba(37, 99, 235, 0.08) 100%
  );
  border-bottom-color: #2a2d3a;
}

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

[data-theme="dark"] .accordion-header:not(.active) h3 {
  color: #a0a0a0;
}

[data-theme="dark"] .accordion-body {
  background: #23262f;
  border-color: #2a2d3a;
}

[data-theme="dark"] .accordion-icon {
  color: #a0a0a0;
}

[data-theme="dark"] .accordion-header.active .accordion-icon {
  color: #60a5fa;
}

[data-theme="dark"] .accordion-number {
  background: #2563eb;
}

[data-theme="dark"] .walaka-barcode-scan-section {
  background: linear-gradient(
    135deg,
    rgba(37, 99, 235, 0.12) 0%,
    rgba(37, 99, 235, 0.04) 100%
  );
  border-color: #2a2d3a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .walaka-barcode-scan-title {
  color: #e8eaed;
}

[data-theme="dark"] .walaka-barcode-scan-desc,
[data-theme="dark"] .walaka-barcode-scan-label {
  color: #a8adb8;
}

[data-theme="dark"] .walaka-beta-pill {
  color: #93c5fd;
  background: rgba(37, 99, 235, 0.25);
  border-color: rgba(96, 165, 250, 0.45);
}

[data-theme="dark"] .walaka-barcode-scan-input {
  background: #1e2128;
  border-color: #3d4450;
  color: #e8eaed;
}

[data-theme="dark"] .walaka-barcode-scan-input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
}

[data-theme="dark"] .walaka-barcode-camera-btn {
  border-color: #3d4450;
  box-shadow: none;
}

/* Contas de Pagamento para Factura – texto dentro dos cards, à frente, sem deslocar */
#payment-accounts-checkboxes {
  align-items: stretch;
}
#payment-accounts-checkboxes .payment-account-card {
  margin: 0;
  box-sizing: border-box;
  min-width: 0; /* permite o card encolher dentro da célula da grelha */
  overflow: hidden; /* conteúdo fica dentro do card */
  position: relative;
}
#payment-accounts-checkboxes .payment-account-card-content {
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  overflow: hidden;
  position: relative;
  z-index: 1; /* texto à frente do fundo do card */
}
#payment-accounts-checkboxes .payment-account-card-content > div {
  visibility: visible !important;
  display: block !important;
}

/* Fix layout drift in invoice modal payment account cards */
#payment-accounts-selection-container #payment-accounts-checkboxes {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
  gap: 12px !important;
  align-items: stretch;
}

#payment-accounts-checkboxes .payment-account-card {
  display: flex !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  min-width: 0;
  text-align: left !important;
}

#payment-accounts-checkboxes .payment-account-card input[type="checkbox"],
#payment-accounts-checkboxes .payment-account-checkbox {
  width: 16px !important;
  min-width: 16px !important;
  max-width: 16px !important;
  height: 16px !important;
  flex: 0 0 16px !important;
  margin: 4px 0 0 0 !important;
  padding: 0 !important;
  align-self: flex-start !important;
}

#payment-accounts-checkboxes .payment-account-card-content {
  flex: 1 1 auto !important;
  width: auto !important;
  max-width: 100% !important;
  min-width: 0;
  overflow: visible !important;
  text-align: left !important;
}

#payment-accounts-checkboxes .payment-account-card-content > div {
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: anywhere !important;
}

[data-theme="dark"] #payment-accounts-checkboxes .payment-account-card {
  background: var(--card-background, #2a2d3a);
  border-color: var(--border-color, #3d4150);
}

/* ============================================
   REQUIRED FIELD VALIDATION STYLES
   ============================================ */

/* Required field asterisk - using inline span */
.required-asterisk {
  color: #dc3545;
  font-weight: 700;
  margin-left: 2px;
}

/* Dark mode support for required asterisk */
[data-theme="dark"] .required-asterisk {
  color: #ef4444;
}

/* Error state for invalid fields */
.modal-invoice input.field-error,
.modal-invoice select.field-error,
.modal-invoice textarea.field-error,
.document-modal input.field-error,
.document-modal select.field-error,
.document-modal textarea.field-error {
  border-color: #dc3545 !important;
  border-width: 2px !important;
  background-color: #fff5f5 !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15) !important;
}

/* Dark mode error state */
[data-theme="dark"] .modal-invoice input.field-error,
[data-theme="dark"] .modal-invoice select.field-error,
[data-theme="dark"] .modal-invoice textarea.field-error,
[data-theme="dark"] .document-modal input.field-error,
[data-theme="dark"] .document-modal select.field-error,
[data-theme="dark"] .document-modal textarea.field-error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.1) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* Field error message */
.field-error-message {
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.field-error-message::before {
  content: "\f071";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.75rem;
}

[data-theme="dark"] .field-error-message {
  color: #ef4444;
}

/* Custom select trigger error state */
.custom-select-trigger.field-error {
  border-color: #dc3545 !important;
  border-width: 2px !important;
  background-color: #fff5f5 !important;
}

[data-theme="dark"] .custom-select-trigger.field-error {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.1) !important;
}

/* Smooth transition for error states */
.modal-invoice input,
.modal-invoice select,
.modal-invoice textarea,
.document-modal input,
.document-modal select,
.document-modal textarea,
.custom-select-trigger {
  transition: border-color 0.2s ease, background-color 0.2s ease,
    box-shadow 0.2s ease;
}

[data-theme="dark"] .accordion-header:not(.active) .accordion-number {
  background: #3a3d4a;
  color: #888;
}

[data-theme="dark"] .invoice-form-actions {
  background: #2a2d3a;
  border-color: #2a2d3a;
}

/* Form Sections within Accordion */
.accordion-body .form-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.accordion-body .form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.accordion-body .form-section h4 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary-color, #007ec7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

[data-theme="dark"] .accordion-body .form-section {
  border-bottom-color: #2a2d3a;
}

[data-theme="dark"] .accordion-body .form-section h4 {
  color: #60a5fa;
}

/* Checkbox Styling */
.form-checkbox {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  cursor: pointer;
  accent-color: var(--primary-color, #007ec7);
  vertical-align: middle;
}

.form-group label:has(.form-checkbox) {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 10px 0;
  user-select: none;
}

.form-group label:has(.form-checkbox):hover {
  color: var(--primary-color, #007ec7);
}

.form-group label:has(.form-checkbox) span {
  font-weight: 500;
  font-size: 14px;
}

[data-theme="dark"] .form-checkbox {
  accent-color: #60a5fa;
}

[data-theme="dark"] .form-group label:has(.form-checkbox):hover {
  color: #60a5fa;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .accordion-header {
    padding: 14px 16px;
  }

  .accordion-number {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .accordion-header h3 {
    font-size: 16px;
  }

  .accordion-body {
    padding: 16px;
  }

  .invoice-form-actions {
    flex-direction: column;
    padding: 16px;
  }

  .invoice-form-actions .btn {
    width: 100%;
    min-width: auto;
  }
}

@media (max-width: 480px) {
  .accordion-header {
    padding: 12px;
  }

  .accordion-header-content {
    gap: 12px;
  }

  .accordion-number {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .accordion-header h3 {
    font-size: 15px;
  }

  .accordion-body {
    padding: 12px;
  }
}

/* Form Footer */
.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-color);
}

.form-footer-left,
.form-footer-right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.form-footer-left {
  margin-right: auto;
}

/* Responsive styles for form footer */
@media (max-width: 768px) {
  .form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .form-footer-left,
  .form-footer-right {
    width: 100%;
    justify-content: space-between;
  }

  .form-footer-left {
    margin-bottom: 1rem;
  }
}

/* Mobile optimizations will be handled in mobile-optimizations.css */

/* AI Notes Assistant Styles */
.ai-notes-suggestions {
  margin-top: 8px;
  border-radius: 6px;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.ai-notes-suggestions .suggestions-header {
  padding: 8px 12px;
  background: var(--primary-color);
  color: white;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-notes-suggestions .suggestion-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-notes-suggestions .suggestion-item:hover {
  background: var(--hover-background);
}

.ai-notes-suggestions .suggestion-item:last-child {
  border-bottom: none;
}

.ai-notes-suggestions .suggestion-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}

.ai-notes-suggestions .use-suggestion-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  margin-left: 8px;
}

.ai-notes-suggestions .use-suggestion-btn:hover {
  background: var(--primary-color);
  color: white;
}

.ai-notes-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.ai-suggestions-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  background: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.ai-suggestions-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.clear-suggestions-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.clear-suggestions-btn:hover {
  background: var(--hover-background);
  border-color: var(--text-secondary);
}

/* Dark mode support for AI notes */
[data-theme="dark"] .ai-notes-suggestions {
  background: var(--card-background);
  border-color: var(--border-color);
}

[data-theme="dark"] .ai-notes-suggestions .suggestion-item:hover {
  background: var(--hover-background);
}

[data-theme="dark"] .ai-notes-suggestions .suggestion-text {
  color: var(--text-primary);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #000000;
  margin-bottom: 0.25rem;
}

.page-header .subtitle {
  color: #666;
  font-size: 0.9rem;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

/* Buttons */
.btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--card-radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  border: none;
}

.icon-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.primary-btn {
  background-color: #007ec7;
  color: white;
}

.primary-btn:hover {
  background-color: #0066a1;
  transform: translateY(-1px);
}

.secondary-btn {
  background-color: #f0f0f0;
  color: #444;
}

.secondary-btn:hover {
  background-color: #e0e0e0;
  transform: translateY(-1px);
}

/* Invoice Table */
.invoice-table-container {
  background: rgb(255, 255, 255);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  box-shadow: var(--box-shadow);
  margin-bottom: 1.5rem;
}

.table-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.table-header h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: #222;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9rem;
}

.data-table th {
  color: #777;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
}

.data-table tbody tr {
  transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
  background-color: #f9f9f9;
}

.data-table td {
  color: #333;
}

/* Status Styles */
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 500;
}

.status i {
  margin-right: 6px;
}

/* Status Colors */
.status.gray {
  background-color: #f3f4f6;
  color: #6b7280;
}

.status.blue {
  background-color: #e0f2fe;
  color: #0284c7;
}

.status.orange {
  background-color: #fff7ed;
  color: #ea580c;
}

.status.green {
  background-color: #f0fdf4;
  color: #16a34a;
}

.status.red {
  background-color: #fef2f2;
  color: #dc2626;
}

/* Timeline Styles */
.status-timeline {
  margin-top: 20px;
  padding: 20px;
  background: #f8fafc;
  border-radius: 8px;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 20px;
  position: relative;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e2e8f0;
  margin-right: 12px;
  margin-top: 4px;
}

.timeline-item.active .timeline-marker {
  background: var(--primary-color);
}

.timeline-content {
  flex: 1;
}

.timeline-date {
  display: block;
  font-size: 0.85em;
  color: #64748b;
  margin-bottom: 4px;
}

.timeline-title {
  font-weight: 500;
  color: #1e293b;
}

/* Status Action Buttons */
.status-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.status-actions button {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.2s;
}

.status-actions button i {
  margin-right: 6px;
}

/* Status Badge in Invoice Header */
.invoice-view-header .status {
  font-size: 1em;
  padding: 6px 12px;
}

/* Status Filter Dropdown */
#statusFilter {
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  background-color: white;
  min-width: 150px;
}

#statusFilter option {
  padding: 8px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  font-size: 0.9rem;
}

.page-info {
  color: #666;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e0e0e0;
  background-color: white;
  border-radius: 4px;
  color: #555;
  cursor: pointer;
  font-size: 0.85rem;
}

.pagination-btn.active {
  background-color: #007ec7;
  color: white;
  border-color: #007ec7;
}

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

.pagination-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  color: #777;
}

/* Chart Period Controls */
.chart-period-btn {
  background: #f0f0f0;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease;
  color: #555;
}

.chart-period-btn:hover {
  background: #e0e0e0;
}

.chart-period-btn.active {
  background: #007ec7;
  color: white;
}

/* Modal Styling */
.modal {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: transparent; /* Remove background to prevent double overlay */
}

.modal.active {
  display: flex; /* Show the modal when the active class is present */
  /* The other properties like position, z-index, etc., are inherited from .modal or can be redefined here if needed */
  /* Ensure it's centered or positioned as desired */
  align-items: center; /* Center content vertically */
  justify-content: center; /* Center content horizontally */
}

/* Prevent body scrolling when modal is active */
body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.1); /* 10% opacity - subtle overlay */
  z-index: 1000; /* Lower z-index than the modal */
}

.modal-overlay.active {
  display: block; /* Show the overlay when the active class is present */
}

.modal-content {
  background-color: #fff;
  margin: 1.5rem auto;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: modalFadeIn 0.3s;
  border: 1px solid #e0e0e0;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  background: #fafbfc;
}

.modal-header h2 {
  font-size: 1.5rem;
  color: #222;
  margin: 0;
}

.close-modal {
  font-size: 1.5rem;
  font-weight: 700;
  color: #aaa;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-modal:hover {
  color: #555;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  background: var(--card-background);
}

/* Modal form specific styles */
.modal .form-group {
  margin-bottom: 1rem;
}

.modal .form-group:last-child {
  margin-bottom: 0;
}

/* Product modal specific styles */
#quickAddProductModal .modal-content {
  max-width: 500px;
  max-height: 80vh;
}

/* Dark mode support for quick add product modal */
[data-theme="dark"] #quickAddProductModal .modal-content {
  background: #23262f !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] #quickAddProductModal .modal-header {
  background: #23262f !important;
  border-bottom-color: #2a2d3a !important;
}

[data-theme="dark"] #quickAddProductModal .modal-header h3 {
  color: #60a5fa !important;
}

[data-theme="dark"] #quickAddProductModal .modal-body {
  background: #23262f !important;
}

[data-theme="dark"] #quickAddProductModal .modal-footer {
  background: #23262f !important;
  border-top-color: #2a2d3a !important;
}

[data-theme="dark"] #quickAddProductModal .form-group label {
  color: #e5e7eb !important;
}

[data-theme="dark"] #quickAddProductModal .form-group input,
[data-theme="dark"] #quickAddProductModal .form-group select {
  background: #181a20 !important;
  color: #fff !important;
  border-color: #2a2d3a !important;
}

[data-theme="dark"] #quickAddProductModal .form-group input:focus,
[data-theme="dark"] #quickAddProductModal .form-group select:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2) !important;
}

[data-theme="dark"] #quickAddProductModal .form-group input::placeholder {
  color: #aaa !important;
}

[data-theme="dark"] #quickAddProductModal .btn.secondary-btn {
  background: #2a2d3a !important;
  color: #e0e0e0 !important;
  border-color: #2a2d3a !important;
}

[data-theme="dark"] #quickAddProductModal .btn.primary-btn {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

/* Enhanced dark mode support for all modals */
[data-theme="dark"] .modal {
  background: rgba(0, 0, 0, 0.6) !important;
}

/* Force immediate application of dark mode styles */
[data-theme="dark"] * {
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease;
}

/* Industry Dropdown Styles */
.industry-dropdown-input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-sizing: border-box;
  cursor: pointer;
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.industry-dropdown-input .selected-text {
  color: #666;
}

.industry-dropdown-input i {
  font-size: 12px;
  color: #666;
}

.industry-dropdown-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.industry-dropdown-list .search-container {
  padding: 8px;
  border-bottom: 1px solid #eee;
}

.industry-dropdown-list .industry-search {
  width: 100%;
  padding: 6px;
  border: 1px solid #ddd;
  border-radius: 3px;
  box-sizing: border-box;
  font-size: 12px;
}

.industry-dropdown-list .industry-options {
  max-height: 150px;
  overflow-y: auto;
}

.industry-dropdown-list .industry-option {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
}

.industry-dropdown-list .industry-option:hover {
  background: #f8f9fa;
}

.industry-dropdown-list .industry-number {
  font-weight: bold;
  color: #333;
}

.industry-dropdown-list .industry-description {
  color: #666;
  text-align: right;
  flex: 1;
  margin-left: 10px;
}

.industry-dropdown-list .custom-option {
  padding: 8px 12px;
  cursor: pointer;
  border-top: 2px solid #007bff;
  background: #f8f9fa;
  font-style: italic;
  color: #007bff;
}

.industry-dropdown-list .custom-option i {
  margin-right: 5px;
}

/* Dark mode support for industry dropdown */
[data-theme="dark"] .industry-dropdown-input {
  background: #2a2d3a !important;
  border-color: #555 !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] .industry-dropdown-input .selected-text {
  color: #e0e0e0 !important;
}

[data-theme="dark"] .industry-dropdown-input i {
  color: #e0e0e0 !important;
}

[data-theme="dark"] .industry-dropdown-list {
  background: #2a2d3a !important;
  border-color: #555 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .industry-dropdown-list .search-container {
  border-bottom-color: #444 !important;
}

[data-theme="dark"] .industry-dropdown-list .industry-search {
  background: #181a20 !important;
  border-color: #555 !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] .industry-dropdown-list .industry-search::placeholder {
  color: #888 !important;
}

[data-theme="dark"] .industry-dropdown-list .industry-option {
  border-bottom-color: #444 !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] .industry-dropdown-list .industry-option:hover {
  background: #32353f !important;
}

[data-theme="dark"] .industry-dropdown-list .industry-number {
  color: #60a5fa !important;
}

[data-theme="dark"] .industry-dropdown-list .industry-description {
  color: #e0e0e0 !important;
}

[data-theme="dark"] .industry-dropdown-list .custom-option {
  background: #32353f !important;
  border-top-color: #60a5fa !important;
  color: #60a5fa !important;
}

[data-theme="dark"] .modal-content {
  background: #23262f !important;
  color: #e0e0e0 !important;
  border-color: #2a2d3a !important;
}

[data-theme="dark"] .modal-header {
  background: #23262f !important;
  border-bottom-color: #2a2d3a !important;
}

[data-theme="dark"] .modal-header h3 {
  color: #60a5fa !important;
}

[data-theme="dark"] .modal-body {
  background: #23262f !important;
}

[data-theme="dark"] .modal-footer {
  background: #23262f !important;
  border-top-color: #2a2d3a !important;
}

[data-theme="dark"] .form-group label {
  color: #e5e7eb !important;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: #181a20 !important;
  color: #fff !important;
  border-color: #2a2d3a !important;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2) !important;
}

[data-theme="dark"] .form-group input::placeholder,
[data-theme="dark"] .form-group textarea::placeholder {
  color: #aaa !important;
}

/* Modal Action Button Styles */
.modal-footer .primary-btn,
.modal-footer .secondary-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  min-width: 120px;
  text-align: center;
}

.modal-footer .primary-btn {
  background-color: var(--primary-color, #007ec7);
  color: white;
  border-color: var(--primary-color, #007ec7);
}

.modal-footer .primary-btn:hover {
  background-color: #0066a1;
  border-color: #0066a1;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 126, 199, 0.3);
}

.modal-footer .secondary-btn {
  background-color: #f8f9fa;
  color: #495057;
  border-color: #dee2e6;
}

.modal-footer .secondary-btn:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Dark mode modal footer button styles */
[data-theme="dark"] .modal-footer {
  background: var(--card-background);
  border-top-color: var(--border-color);
}

[data-theme="dark"] .modal-footer .primary-btn {
  background-color: var(--primary-color, #2563eb);
  border-color: var(--primary-color, #2563eb);
  color: white;
}

[data-theme="dark"] .modal-footer .primary-btn:hover {
  background-color: #1d4ed8;
  border-color: #1d4ed8;
}

[data-theme="dark"] .modal-footer .secondary-btn {
  background-color: #374151;
  color: #e5e7eb;
  border-color: #4b5563;
}

[data-theme="dark"] .modal-footer .secondary-btn:hover {
  background-color: #4b5563;
  border-color: #6b7280;
}

/* --- Dark mode and mobile improvements (sticky, visible step footer) --- */
/* Make the step footer sticky and clearly separated from content on all viewports */
.modal-invoice .step-footer {
  position: sticky;
  bottom: 0;
  background: var(--card-background, #fff);
  border-top: 1px solid var(--border-color, #e0e0e0);
  z-index: 5;
}

[data-theme="dark"] .modal-invoice .step-footer {
  background: #23262f !important;
  border-color: #2a2d3a !important;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .modal-invoice .step-footer .btn.primary-btn {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

[data-theme="dark"] .modal-invoice .step-footer .btn.secondary-btn {
  background: #2a2d3a !important;
  color: #e5e7eb !important;
  border: 1px solid #374151 !important;
}

/* Form Styling */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-section {
  margin-bottom: 1.5rem;
}

.form-section h3 {
  font-size: 1.1rem;
  color: #333;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  max-width: none; /* Override any external max-width constraints */
  width: 100%;
  box-sizing: border-box;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent flex item overflow */
}

.form-group label {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #007ec7;
  outline: none;
  box-shadow: 0 0 0 2px rgb(255, 255, 255);
}

.form-group input[readonly] {
  background-color: var(--background-color);
  cursor: not-allowed;
}

/* Radio Button Styles */
.radio-group {
  display: flex;
  flex-direction: row;
  gap: 2rem;
  margin-top: 0.5rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-primary);
  padding: 0.5rem 0;
}

.radio-label input[type="radio"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.radio-label span {
  font-weight: 500;
}

/* Dark mode radio button styles */
[data-theme="dark"] .radio-label {
  color: var(--text-primary);
}

[data-theme="dark"] .radio-label input[type="radio"] {
  accent-color: var(--primary-color);
}

/* Items Table */
.items-table-container {
  margin-bottom: 1rem;
  border: 1px solid #c7c7c7;
  border-radius: 4px;
  overflow-x: auto; /* Allow horizontal scrolling */
  max-width: 100%;
  padding: 0.5rem;
}

.items-table {
  width: 100%;
  min-width: 800px; /* Ensure minimum width for all columns */
  border-collapse: collapse;
  table-layout: fixed; /* Fixed layout for better column control */
}

.items-table th,
.items-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
  overflow: visible;
  position: relative; /* Ensure positioning context for children */
  vertical-align: middle;
}

.items-table th {
  background-color: var(--background-color);
  font-weight: 600;
  color: var(--text-primary);
}

.items-table input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  min-height: 36px;
  box-sizing: border-box;
}

.items-table select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  min-height: 36px;
  box-sizing: border-box;
  background: white;
}

.remove-item-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background-color: var(--background-color);
  color: #e55353;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.remove-item-btn:hover {
  background-color: #fcebeb;
}

.invoice-totals {
  margin-top: 1.5rem;
  margin-left: auto;
  width: 300px;
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  border-bottom: 1px solid #e9ecef;
}

.totals-row:last-child {
  border-bottom: none;
  font-weight: 600;
  font-size: 1rem;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  color: #007ec7;
}

.totals-row:last-child {
  font-weight: 600;
  font-size: 1rem;
  padding-top: 0.75rem;
  border-top: 2px solid #eee;
  margin-top: 0.5rem;
}

/* View Invoice Modal */
.invoice-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.invoice-view-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.invoice-view-info h3 {
  margin: 0;
  font-size: 1.2rem;
}

.invoice-view-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.template-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.5rem;
}

.template-selector label {
  font-size: 0.85rem;
  color: #555;
}

.template-selector select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
}

.invoice-preview-container {
  width: 100%;
  height: 100vh;
  overflow: auto;
  margin-bottom: 1.5rem;
  background: #f5f5f5;
  padding: 20px;
}

#invoicePreviewFrame {
  width: 100%;
  height: 100%;
  border: none;
}

.invoice-view-footer {
  margin-top: 1.5rem;
}

.payment-status h4 {
  font-size: 1rem;
  color: #333;
  margin-bottom: 1rem;
}

/* Date Range Picker Styles */
.date-range-group {
  position: relative;
}

.custom-date-range {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background: var(--card-background);
  border: 1px solid var(--border-color, #ddd);
  border-radius: var(--border-radius, 4px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  z-index: 1000;
  width: 300px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.custom-date-range[style*="display: block"] {
  opacity: 1;
  visibility: visible;
}

.date-range-group select:focus + .custom-date-range {
  display: block;
}

/* Close button for custom date range */
.custom-date-range::before {
  content: "×";
  position: absolute;
  top: 5px;
  right: 8px;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  line-height: 1;
}

.custom-date-range::before:hover {
  color: #333;
}

/* Date Range Filter Styles */
.date-range-group {
  position: relative;
  margin-right: 1rem;
}

.date-range-group select {
  min-width: 150px;
}

.custom-date-range {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background: var(--card-background);
  border: 1px solid var(--border-color, #ddd);
  border-radius: var(--border-radius, 4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  z-index: 1000;
  width: 300px;
}

.date-input-group {
  margin-bottom: 1rem;
}

.date-input-group:last-of-type {
  margin-bottom: 0.5rem;
}

.date-input-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-muted, #666);
}

.date-input-group input[type="date"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color, #ddd);
  border-radius: var(--border-radius, 4px);
  font-size: 0.875rem;
}

#applyDateRange {
  width: 100%;
  padding: 0.5rem;
  background-color: var(--primary-color, #007bff);
  color: white;
  border: none;
  border-radius: var(--border-radius, 4px);
  cursor: pointer;
  font-size: 0.875rem;
  transition: background-color 0.2s;
}

#applyDateRange:hover {
  background-color: var(--primary-color-dark, #0056b3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .date-range-group {
    margin-right: 0;
    margin-bottom: 1rem;
  }

  .custom-date-range {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 300px;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .form-row {
    flex-direction: column;
    gap: 1rem;
  }

  .action-buttons {
    flex-direction: column;
    gap: 0.5rem;
  }

  .invoice-view-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .invoice-view-actions {
    width: 100%;
    justify-content: space-between;
  }

  .modal-content {
    width: 95%;
    margin: 1rem auto;
  }
}

/* --- Robust [data-theme="dark"] rules for modal and table dark mode --- */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .modal-footer,
[data-theme="dark"] .invoice-table-container,
[data-theme="dark"] .items-table,
[data-theme="dark"] .items-table th,
[data-theme="dark"] .items-table td {
  background: #23262f !important;
  color: #fff !important;
  border-color: #2a2d3a !important;
}
[data-theme="dark"] .modal-header h2,
[data-theme="dark"] .modal-header h3,
[data-theme="dark"] .modal-body h3,
[data-theme="dark"] .modal-body h4,
[data-theme="dark"] .items-table th {
  color: #60a5fa !important;
}
[data-theme="dark"] .form-group label,
[data-theme="dark"] .modal label {
  color: #e5e7eb !important;
}
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: #181a20 !important;
  color: #fff !important;
  border-color: #2a2d3a !important;
}
[data-theme="dark"] .form-group input:disabled,
[data-theme="dark"] .form-group select:disabled,
[data-theme="dark"] .form-group textarea:disabled {
  background: #23262f !important;
  color: #aaa !important;
}
[data-theme="dark"] .modal-stepper .step-indicator {
  background: #181a20 !important;
  color: #aaa !important;
  border: 1px solid #333 !important;
  border-bottom: none !important;
}
[data-theme="dark"] .modal-stepper .step-indicator.active {
  background: #2563eb !important;
  color: #fff !important;
  border-bottom: 2px solid #60a5fa !important;
}
[data-theme="dark"] .modal-stepper .step-indicator:not(.active) {
  color: #aaa !important;
}
[data-theme="dark"] .modal-overlay {
  background: rgba(
    0,
    0,
    0,
    0.1
  ) !important; /* 10% opacity - subtle overlay in dark mode */
}

/* Dark mode – invoices table container and inner table (desktop + mobile) */
[data-theme="dark"] .invoice-table-container {
  background: #23262f !important;
  border-color: #2a2d3a !important;
}
[data-theme="dark"] .invoice-table-container .table-responsive {
  background: #23262f !important;
}
[data-theme="dark"] .invoice-table-container .data-table,
[data-theme="dark"] .invoice-table-container .data-table th,
[data-theme="dark"] .invoice-table-container .data-table td {
  background: #23262f !important;
  color: #fff !important;
  border-color: #2a2d3a !important;
}

[data-theme="dark"] .action-dropdown {
  background: #23262f !important;
  border-color: #2a2d3a !important;
  color: #fff !important;
}

[data-theme="dark"] .dropdown-header {
  background-color: #181a20 !important;
  border-bottom-color: #2a2d3a !important;
  color: #60a5fa !important;
}

[data-theme="dark"] .dropdown-item {
  color: #e5e7eb !important;
}

[data-theme="dark"] .dropdown-item:hover {
  background-color: #181a20 !important;
}

[data-theme="dark"] .dropdown-item i {
  color: #60a5fa !important;
}

[data-theme="dark"] .dropdown-item-danger {
  color: #f87171 !important;
}

[data-theme="dark"] .dropdown-item-danger:hover {
  background-color: #1f2937 !important;
}

[data-theme="dark"] .dropdown-item-danger i {
  color: #f87171 !important;
}
[data-theme="dark"] .btn,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn.secondary-btn {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}
[data-theme="dark"] .btn:hover,
[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn.secondary-btn:hover {
  background: #1e40af !important;
  color: #fff !important;
}
[data-theme="dark"] ::-webkit-scrollbar {
  width: 12px;
  background: #23262f;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 6px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #2563eb;
}
[data-theme="dark"] ::-webkit-scrollbar-corner {
  background: #23262f;
}
[data-theme="dark"] {
  scrollbar-color: #444 #23262f;
  scrollbar-width: thin;
}

/* Chart Card */
.chart-card {
  background: var(--card-background);
  color: var(--text-primary);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  box-shadow: var(--box-shadow);
  margin-bottom: 1.5rem;
}

.suggestion-box {
  font-size: 14px;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}

.suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background-color: #f5f5f5;
}

.item-description-wrapper {
  position: relative;
  width: 100%;
  overflow: visible;
}

.product-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
}

.product-suggestions .suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.product-suggestions .suggestion-item:last-child {
  border-bottom: none;
}

.product-suggestions .suggestion-item:hover {
  background-color: #f5f5f5;
}

.product-suggestions .suggestion-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-suggestions .suggestion-name {
  font-weight: 500;
  color: var(--text-primary);
}

.product-suggestions .suggestion-price {
  color: #666;
  font-size: 0.9em;
  font-weight: 500;
}

.product-suggestions .suggestion-details {
  display: flex;
  gap: 12px;
  font-size: 0.8em;
  color: var(--text-secondary);
}

.product-suggestions .suggestion-type {
  background: var(--primary-color);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75em;
  font-weight: 500;
}

.product-suggestions .suggestion-category {
  background: var(--border-color);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.75em;
}

.product-suggestions .suggestion-item .product-name {
  font-weight: 500;
}

.product-suggestions .suggestion-item .product-price {
  color: #666;
  font-size: 0.9em;
}

/* Header and empty state for product suggestions */
.suggestions-header {
  position: sticky;
  top: 0;
  background: var(--background-color);
  color: var(--text-primary);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
  z-index: 1;
}
.no-suggestions {
  padding: 10px 12px;
  color: #777;
}

/* Dark mode styling for suggestion dropdown */
[data-theme="dark"] .product-suggestions {
  background: #23262f !important;
  border-color: #2a2d3a !important;
  box-shadow: 0 2px 8px #181a20 !important;
}
[data-theme="dark"] .suggestions-header {
  background: #181a20 !important;
  color: #60a5fa !important;
  border-bottom-color: #2a2d3a !important;
}
[data-theme="dark"] .product-suggestions .suggestion-item span {
  color: #fff !important;
}
[data-theme="dark"] .product-suggestions .suggestion-name {
  color: #fff !important;
}
[data-theme="dark"] .product-suggestions .suggestion-price {
  color: #60a5fa !important;
}
[data-theme="dark"] .product-suggestions .suggestion-details {
  color: #aaa !important;
}
[data-theme="dark"] .product-suggestions .suggestion-type {
  background: #3b82f6 !important;
  color: white !important;
}
[data-theme="dark"] .product-suggestions .suggestion-category {
  background: #2a2d3a !important;
  color: #e0e0e0 !important;
}
[data-theme="dark"] .product-suggestions .suggestion-item .product-price,
[data-theme="dark"] .product-suggestions .suggestion-item .suggestion-price {
  color: #60a5fa !important;
}
[data-theme="dark"] .no-suggestions {
  color: #9aa4b2 !important;
}

/* Strong light-mode isolation for content rendered inside PDF container */
[data-theme="dark"] .pdf-root {
  background: #ffffff !important;
  color: #000000 !important;
}
[data-theme="dark"] .pdf-root .invoice-container {
  background: #ffffff !important;
  color: #000000 !important;
}
[data-theme="dark"] .pdf-root .invoice-items td,
[data-theme="dark"] .pdf-root .invoice-items tbody td,
[data-theme="dark"] .pdf-root p,
[data-theme="dark"] .pdf-root span,
[data-theme="dark"] .pdf-root li,
[data-theme="dark"] .pdf-root .client-info,
[data-theme="dark"] .pdf-root .invoice-details {
  color: #000000 !important;
}
[data-theme="dark"] .pdf-root .invoice-items td {
  border-bottom: 1px solid #eeeeee !important;
}

.dropdown-menu {
  position: fixed; /* Use fixed position to avoid issues with table scrolling */
  background-color: var(--card-background); /* Use a variable or default */
  border: 1px solid var(--border-color, #e0e0e0); /* Use a variable or default */
  border-radius: var(--card-radius); /* Use the defined card radius */
  box-shadow: var(--box-shadow); /* Use the defined box shadow */
  z-index: 1000; /* Ensure it's above other content */
  min-width: 150px;
  display: none; /* Hidden by default, shown by JS */
  padding: 0.5rem 0; /* Add some vertical padding */
}

.dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem; /* Slightly smaller font size */
  color: var(--text-color, #333); /* Use a variable or default */
  display: flex; /* Use flexbox for icon and text alignment */
  align-items: center;
  gap: 0.5rem; /* Space between icon and text */
}

.dropdown-item:hover {
  background-color: var(
    --hover-background-color,
    #f0f0f0
  ); /* Use a variable or default */
  color: var(--primary-color, #007ec7); /* Highlight text on hover */
}

.dropdown-item i {
  width: 1rem; /* Fixed width for icons */
  text-align: center;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.export-buttons {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.export-buttons button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.export-buttons button i {
  font-size: 1rem;
}

.export-buttons .btn-success {
  background-color: #28a745;
  color: white;
}

.export-buttons .btn-success:hover {
  background-color: #218838;
}

.export-buttons .btn-primary {
  background-color: #007bff;
  color: white;
}

.export-buttons .btn-primary:hover {
  background-color: #0056b3;
}

.export-buttons button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.export-buttons button:disabled i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Action Menu */
.action-menu {
  position: relative;
  display: flex;
  justify-content: center;
}

.action-menu-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  color: #555;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.action-menu-btn:hover {
  background-color: #f0f0f0;
  color: #007ec7;
}

/* Action Dropdown */
.action-dropdown {
  position: absolute;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  max-width: 280px;
  z-index: 1000;
  overflow: hidden;
  animation: dropdownFadeIn 0.2s ease;
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-header {
  padding: 12px 16px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  font-weight: 600;
  font-size: 14px;
  color: #333;
}

.dropdown-content {
  padding: 8px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: #333;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  text-align: left;
}

.dropdown-item:hover {
  background-color: #f8f9fa;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  color: #666;
}

.dropdown-item span {
  flex: 1;
}

.dropdown-divider {
  height: 1px;
  background-color: #e0e0e0;
  margin: 8px 0;
}

.dropdown-item-danger {
  color: #dc3545;
}

.dropdown-item-danger:hover {
  background-color: #fff5f5;
}

.dropdown-item-danger i {
  color: #dc3545;
}

/* Mobile responsive styles for action dropdown */
@media (max-width: 768px) {
  .action-dropdown {
    min-width: 180px;
    max-width: 250px;
    max-height: 70vh;
    font-size: 14px;
  }

  .dropdown-header {
    padding: 10px 12px;
    font-size: 13px;
  }

  .dropdown-item {
    padding: 8px 12px;
    font-size: 13px;
    gap: 8px;
  }

  .dropdown-item i {
    width: 14px;
    font-size: 12px;
  }
}

/* --- Modal Stepper Styles --- */
.modal-stepper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 0 8px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--background-color, #f8f9fa);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.modal-stepper::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--primary-color, #007ec7) 0%,
    rgba(0, 126, 199, 0.6) 100%
  );
  z-index: 1;
}

.step-indicator {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-bottom: 3px solid transparent;
  color: #888;
  font-weight: 500;
  position: relative;
  transition: all 0.3s ease;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 2;
  border-radius: 0;
  font-size: 1.1rem;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-indicator.active {
  color: var(--primary-color, #007ec7);
  background: rgba(0, 126, 199, 0.1);
  position: relative;
}

.step-indicator.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-color, #007ec7);
  border-radius: 0;
}

.step-indicator:not(.active):hover {
  background: rgba(0, 126, 199, 0.05);
  color: var(--text-primary, #333);
}

.step-indicator:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 24px;
  background: #e0e0e0;
  z-index: 1;
}

/* --- Step Content --- */
.step {
  display: none;
  animation: fadeIn 0.3s;
  margin-bottom: 1rem;
}
.step.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Step Footer Buttons --- */
.step-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* --- Review Section --- */
.review-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 1rem;
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid #e9ecef;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.review-section table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  margin-top: 1rem;
  background: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.review-section th,
.review-section td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9rem;
  background: white;
}

.review-section tr:last-child td {
  border-bottom: none;
  font-weight: 600;
  background: #f8f9fa;
}

.step-content-wrapper h3 {
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #007ec7;
  display: inline-block;
}

.review-section th {
  background: #e9ecef;
  font-weight: 600;
  color: #495057;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Custom Select (Dropdown) - Desktop & Mobile ===== */
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 2.25rem 0.75rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  color: #333;
  font-size: 16px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.custom-select-trigger:focus,
.custom-select-trigger[aria-expanded="true"] {
  outline: none;
  border-color: #007ec7;
  box-shadow: 0 0 0 3px rgba(0, 126, 199, 0.1);
}
.custom-select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat center / contain;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat center / contain;
  color: #666;
}
.custom-options {
  position: fixed; /* evita clipping dentro do modal */
  /* Deve ficar acima de modais e do fx-popover (z-index 100001). */
  z-index: 200000;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 50vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* scroll suave em iOS */
  overscroll-behavior: contain; /* evita propagar scroll para o body */
  padding: 6px 0;
  display: none;
}
.custom-options.open {
  display: block;
}
.custom-option {
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
  cursor: pointer;
  white-space: normal;
}
.custom-option:hover {
  background: #f5f7fb;
}
.custom-option.selected {
  background: #e7f0fb;
  font-weight: 600;
}
.custom-option.is-placeholder {
  color: #999;
  font-style: italic;
}

/* Fonte de câmbio (#fxRateSource): ~30% mais compacto que o select genérico */
.custom-select-trigger.custom-select-trigger--fx-popover {
  font-size: 11.2px;
  min-height: 31px;
  padding: 0.525rem 1.575rem 0.525rem 0.525rem;
}
.custom-select-trigger.custom-select-trigger--fx-popover .custom-select-arrow {
  right: 10px;
  width: 14px;
  height: 14px;
}
.custom-options.custom-options--fx-popover .custom-option {
  padding: 7px 10px;
  font-size: 11.2px;
}

/* Dark mode */
[data-theme="dark"] .custom-select-trigger {
  background: #23262f;
  color: #fff;
  border-color: #444;
}
[data-theme="dark"] .custom-select-arrow {
  color: #aaa;
}
[data-theme="dark"] .custom-options {
  background: #23262f;
  color: #fff;
  border-color: #2a2d3a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .custom-option:hover {
  background: #2a3444;
}
[data-theme="dark"] .custom-option.selected {
  background: #1f3c68;
}

/* ===== Unified FX layout for document creation modals ===== */
.fx-mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}

.fx-mode-row > .fx-mode-group {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
}

.fx-mode-row .form-help-text {
  color: #666;
  font-size: 0.85em;
  display: block;
  margin-top: 6px;
  line-height: 1.35;
}

[data-theme="dark"] .fx-mode-row .form-help-text {
  color: #a4b1c2;
}

.fx-layout {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fx-grid {
  display: grid;
  /* Três colunas com a mesma largura: Moeda | Taxa | Configurar câmbio */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
  align-items: end;
  width: 100%;
}

.fx-grid > * {
  min-width: 0;
}

.fx-currency-group {
  margin: 0;
  flex: 0 1 auto; /* dentro da grelha: não herdar flex:1 de .form-group */
}

.fx-rate-card-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
}

#exchangeRateInfo.fx-rate-card {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-left: none;
  font-size: inherit;
  color: inherit;
  align-self: flex-end;
}

.fx-rate-card-wrap .fx-rate-shell {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* Alinha com .custom-select-trigger (min-height 44px) */
  min-height: 44px;
  justify-content: center;
}

/* Terceira coluna: botão ocupa toda a largura da célula */
.fx-grid > .fx-config-btn {
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

.fx-rate-shell {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #d4e4f6;
  border-left: 3px solid #007ec7;
  background: #eef6ff;
  padding: 0.35rem 0.55rem;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-height: 40px;
}

.fx-rate-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1px;
}

.fx-rate-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fx-rate-source {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.fx-rate-main {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.15;
}

.fx-rate-sub {
  font-size: 0.68rem;
  color: #4b5563;
  line-height: 1.2;
}

.fx-rate-source-automatic .fx-rate-source,
.fx-rate-source-automatic .fx-rate-main {
  color: #0f8a46;
}

.fx-rate-source-manual {
  border-left-color: #ff9800;
  background: #fff8ec;
}

.fx-rate-source-manual .fx-rate-source,
.fx-rate-source-manual .fx-rate-main {
  color: #b96500;
}

.fx-rate-message.fx-rate-warning {
  border-left-color: #f59e0b;
  background: #fff7e5;
}

.fx-rate-message.fx-rate-warning .fx-rate-main {
  color: #8a6100;
  font-size: 0.92rem;
}

.fx-rate-message.fx-rate-error {
  border-left-color: #dc3545;
  background: #fdecec;
}

.fx-rate-message.fx-rate-error .fx-rate-main {
  color: #8b1e2d;
  font-size: 0.92rem;
}

.fx-rate-message.fx-rate-success {
  border-left-color: #16a34a;
  background: #ecfdf3;
}

.fx-rate-message.fx-rate-success .fx-rate-main {
  color: #166534;
  font-size: 0.92rem;
}

.fx-manual-panel {
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.5rem;
  justify-self: stretch;
  min-width: 220px;
  max-width: 380px;
}

.fx-manual-panel:not(.is-open):not(.is-manual-only) {
  border-color: transparent;
  background: transparent;
  padding: 0;
  justify-self: start;
  min-width: 0;
  max-width: none;
}

.fx-manual-panel.is-open {
  justify-self: start;
}

.fx-manual-panel.is-hidden,
.fx-help.is-hidden,
#exchangeRateInfo.is-hidden {
  display: none !important;
}

.fx-manual-panel.is-open .fx-manual-body {
  display: flex;
}

.fx-manual-panel:not(.is-open) .fx-manual-body {
  display: none;
}

.fx-manual-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.fx-toggle-btn {
  min-height: 36px;
  padding: 0.38rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #0284c7;
  background: #f0f9ff;
  color: #075985;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.fx-toggle-btn:hover {
  background: #e0f2fe;
}

.fx-manual-body {
  margin-top: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.fx-manual-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.fx-manual-row {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr);
  align-items: center;
  gap: 0.5rem;
}

.fx-manual-row > label {
  margin: 0;
  font-size: 0.82rem;
  color: #4b5563;
  white-space: normal;
}

#manualExchangeRate {
  width: 100%;
  min-height: 36px;
  padding: 0.38rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 0.9rem;
}

.fx-actions {
  display: flex;
  justify-content: flex-start;
}

#applyManualRate {
  min-height: 36px;
  padding: 0.38rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #16a34a;
  background: #22c55e;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

#applyManualRate:hover {
  background: #16a34a;
}

#applyManualRate:disabled,
.fx-toggle-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.fx-help {
  font-size: 0.72rem;
  color: #64748b;
  line-height: 1.4;
}

[data-theme="dark"] .fx-rate-shell {
  border-color: #334155;
  background: #1f2937;
  color: #e5e7eb;
}

[data-theme="dark"] .fx-rate-title {
  color: #cbd5e1;
}

[data-theme="dark"] .fx-rate-sub {
  color: #94a3b8;
}

[data-theme="dark"] .fx-rate-source-automatic .fx-rate-source,
[data-theme="dark"] .fx-rate-source-automatic .fx-rate-main {
  color: #86efac;
}

[data-theme="dark"] .fx-rate-source-manual {
  background: #2b2114;
  border-left-color: #f59e0b;
}

[data-theme="dark"] .fx-rate-source-manual .fx-rate-source,
[data-theme="dark"] .fx-rate-source-manual .fx-rate-main {
  color: #fcd34d;
}

[data-theme="dark"] .fx-manual-panel {
  border-color: #334155;
  background: #1f2430;
}

[data-theme="dark"] .fx-manual-label {
  color: #d1d5db;
}

[data-theme="dark"] .fx-manual-row > label {
  color: #94a3b8;
}

[data-theme="dark"] .fx-toggle-btn {
  border-color: #2563eb;
  background: #1e293b;
  color: #93c5fd;
}

[data-theme="dark"] .fx-toggle-btn:hover {
  background: #263449;
}

[data-theme="dark"] #manualExchangeRate {
  background: #23262f;
  color: #fff;
  border-color: #334155;
}

[data-theme="dark"] .fx-help {
  color: #94a3b8;
}

@media (max-width: 1200px) {
  .fx-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fx-manual-panel {
    grid-column: 1 / -1;
    justify-self: stretch;
    max-width: none;
  }
}

@media (max-width: 768px) {
  .fx-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .fx-rate-card-wrap,
  .fx-manual-panel {
    width: 100%;
  }

  #exchangeRateInfo.fx-rate-card {
    width: 100%;
  }

  .fx-rate-card-wrap .fx-rate-shell {
    width: 100%;
  }

  .fx-config-btn {
    width: 100%;
    justify-content: center;
  }

  .fx-manual-row {
    grid-template-columns: 1fr;
  }

  .fx-actions {
    width: 100%;
  }

  #applyManualRate,
  .fx-toggle-btn {
    width: 100%;
  }
}
/* --- Responsive Modal --- */
@media (max-width: 600px) {
  .modal-content {
    padding: 8px;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .items-table-container {
    padding: 0.25rem;
    overflow-x: auto;
  }

  .items-table {
    min-width: 100%;
  }

  .invoice-totals {
    width: 100%;
    margin-left: 0;
    margin-top: 1rem;
  }

  .modal-invoice .modal-content {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .modal-invoice .modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    position: sticky;
    top: 0;
    background: var(--card-background);
    z-index: 10;
    flex-shrink: 0;
  }

  .modal-invoice .modal-body {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    /* Hide scrollbar for cleaner mobile UI */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  /* Hide scrollbar for WebKit browsers (Chrome, Safari) on mobile */
  .modal-invoice .modal-body::-webkit-scrollbar {
    width: 4px;
  }

  .modal-invoice .modal-body::-webkit-scrollbar-track {
    background: transparent;
  }

  .modal-invoice .modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
  }

  [data-theme="dark"] .modal-invoice .modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
  }

  .modal-invoice .modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color, #e0e0e0);
    position: sticky;
    bottom: 0;
    background: var(--card-background);
    z-index: 10;
    flex-shrink: 0;
  }

  /* Extra emphasis for mobile dark mode footer */
  [data-theme="dark"] .modal-invoice .modal-footer {
    background: #23262f !important;
    border-color: #2a2d3a !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.35) !important;
  }

  .modal-stepper {
    flex-direction: row;
    gap: 0;
    margin-bottom: 1rem;
    position: relative;
    border-radius: 0;
    overflow: hidden;
    background: #f8f9fa;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
  }

  .step-indicator {
    font-size: 0.85rem;
    padding: 0.75rem 0.25rem;
    min-height: 40px;
    font-weight: 600;
  }

  /* Improve form field spacing on mobile */
  .form-group {
    margin-bottom: 1rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 0.75rem;
  }

  /* Accordion improvements for mobile */
  .accordion-content {
    padding: 1rem 0.75rem;
  }

  .accordion-header {
    padding: 1rem 0.75rem;
  }

  /* Mobile-optimized form groups */
  .form-group {
    margin-bottom: 1.5rem;
  }

  /* Modal overlay full screen on mobile */
  .modal-overlay {
    background-color: rgba(0, 0, 0, 0.2);
  }

  [data-theme="dark"] .modal-overlay {
    background-color: rgba(0, 0, 0, 0.3);
  }

  /* Modal full screen on mobile */
  .modal {
    overflow: hidden;
  }

  /* Button adjustments for mobile */
  .btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  /* Close button positioning */
  .close {
    font-size: 2rem;
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
  }

  /* Safe area insets for notched devices */
  .modal-invoice .modal-header {
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  .modal-invoice .modal-footer {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  /* Prevent horizontal overflow */
  .modal-body * {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Hide scrollbar on modal-body for cleaner look */
  .modal-body::-webkit-scrollbar {
    width: 2px;
  }

  .modal-body::-webkit-scrollbar-track {
    background: transparent;
  }

  .modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
  }

  .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    font-size: 0.9rem;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
  }

  /* Date inputs optimization */
  input[type="date"],
  input[type="datetime-local"] {
    min-height: 44px; /* Touch-friendly */
    font-size: 16px; /* Prevent zoom on iOS */
  }

  /* Dropdown/Select optimization - Estilo Customizado Completo */
  select {
    min-height: 44px; /* Touch-friendly */
    font-size: 16px; /* Prevent zoom on iOS */
    font-weight: 500;
    color: #333;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem;
    padding-right: 2.5rem;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
  }

  select:focus {
    border-color: #007ec7;
    box-shadow: 0 0 0 3px rgba(0, 126, 199, 0.1);
    outline: none;
  }

  select:active {
    transform: scale(0.98);
  }

  /* Estilo das opções do dropdown */
  select option {
    font-size: 16px;
    font-weight: 500;
    padding: 0.75rem;
    color: #333;
    background-color: #fff;
    line-height: 1.5;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  select option:checked,
  select option:hover {
    background-color: #007ec7;
    color: #fff;
  }

  /* Placeholder/primeira opção dos dropdowns */
  select option:first-child {
    color: #999;
    font-style: italic;
  }

  /* Dark mode para selects */
  [data-theme="dark"] select {
    background-color: #23262f;
    color: #fff;
    border-color: #444;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  }

  [data-theme="dark"] select option {
    background-color: #23262f;
    color: #fff;
  }

  [data-theme="dark"] select option:checked,
  [data-theme="dark"] select option:hover {
    background-color: #007ec7;
    color: #fff;
  }

  [data-theme="dark"] select option:first-child {
    color: #666;
  }

  /* Dropdowns específicos da secção 2 */
  #serie,
  #paymentTerms,
  #currency {
    width: 100% !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    padding: 0.75rem !important;
    padding-right: 2.5rem !important;
    min-height: 44px !important;
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
    background-color: #fff !important;
    color: #333 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 20px !important;
  }

  [data-theme="dark"] #serie,
  [data-theme="dark"] #paymentTerms,
  [data-theme="dark"] #currency {
    background-color: #23262f !important;
    color: #fff !important;
    border-color: #444 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  }

  /* Estilo melhorado para as opções dos dropdowns principais */
  #serie option,
  #paymentTerms option,
  #currency option {
    padding: 0.75rem !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: 1.6 !important;
    color: #333 !important;
    background-color: #fff !important;
    white-space: normal !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
  }

  [data-theme="dark"] #serie option,
  [data-theme="dark"] #paymentTerms option,
  [data-theme="dark"] #currency option {
    color: #fff !important;
    background-color: #23262f !important;
  }

  /* Placeholder/primeira opção dos dropdowns */
  #serie option:first-child,
  #paymentTerms option:first-child,
  #currency option:first-child {
    color: #999 !important;
    font-style: italic !important;
  }

  [data-theme="dark"] #serie option:first-child,
  [data-theme="dark"] #paymentTerms option:first-child,
  [data-theme="dark"] #currency option:first-child {
    color: #666 !important;
  }

  /* Garantir que o dropdown não ultrapassa os limites da tela */
  select[size],
  select[multiple] {
    max-height: 60vh !important;
    overflow-y: auto !important;
  }

  /* Espaçamento entre as opções para melhor legibilidade */
  select option {
    margin: 2px 0 !important;
  }

  /* Estilo para opção selecionada */
  select option:checked {
    background: linear-gradient(0deg, #007ec7 0%, #0098f7 100%) !important;
    background-color: #007ec7 !important;
    color: #fff !important;
    font-weight: 600 !important;
  }

  [data-theme="dark"] select option:checked {
    background: linear-gradient(0deg, #1e3a8a 0%, #2563eb 100%) !important;
    background-color: #2563eb !important;
  }

  /* Estilos para outros selects do formulário */
  .form-select,
  .series-dropdown,
  .taxes-dropdown,
  .item-discount-type,
  .item-vat-rate,
  .form-control select,
  #clientAddressSelect,
  #unloadingAddressSelect,
  #transportExpedition,
  #loadingCountry,
  #unloadingCountry {
    min-height: 44px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    padding: 0.75rem !important;
    padding-right: 2.5rem !important;
    border-radius: 8px !important;
    border: 1px solid #ddd !important;
    background-color: #fff !important;
    color: #333 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 20px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
  }

  [data-theme="dark"] .form-select,
  [data-theme="dark"] .series-dropdown,
  [data-theme="dark"] .taxes-dropdown,
  [data-theme="dark"] .item-discount-type,
  [data-theme="dark"] .item-vat-rate,
  [data-theme="dark"] .form-control select,
  [data-theme="dark"] #clientAddressSelect,
  [data-theme="dark"] #unloadingAddressSelect,
  [data-theme="dark"] #transportExpedition,
  [data-theme="dark"] #loadingCountry,
  [data-theme="dark"] #unloadingCountry {
    background-color: #23262f !important;
    color: #fff !important;
    border-color: #444 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  }

  /* Estilos para selects dentro da tabela de items (menores) */
  .items-table select,
  .item-discount-type,
  .item-vat-rate {
    min-height: 40px !important;
    font-size: 0.9rem !important;
    padding: 0.5rem !important;
    padding-right: 2rem !important;
    background-size: 16px !important;
  }

  /* Product suggestions dropdown */
  .product-suggestions {
    position: fixed;
    top: auto;
    left: 1rem;
    right: 1rem;
    width: calc(100% - 2rem);
    max-height: 60vh;
    z-index: 1050;
  }

  .suggestion-item {
    padding: 1rem;
    min-height: 44px;
  }

  /* Custom date range on mobile */
  .custom-date-range {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    z-index: 1050;
  }

  /* Ensure proper spacing for checkbox and radio inputs */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
  }

  .form-group input:focus,
  .form-group select:focus,
  .form-group textarea:focus {
    border-color: var(--primary-color, #007ec7);
    box-shadow: 0 0 0 2px rgba(0, 126, 199, 0.1);
    outline: none;
  }

  /* Mobile-optimized step footer */
  .step-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .step-footer .btn {
    flex: 1;
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-height: 44px;
  }

  /* Mobile-optimized items table */
  .items-table-container {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color, #e0e0e0);
  }

  .items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
  }

  .items-table th {
    background: var(--background-color, #f8f9fa);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary, #666);
    border-bottom: 2px solid var(--border-color, #e0e0e0);
    font-size: 0.85rem;
  }

  .items-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    vertical-align: top;
  }

  .items-table input,
  .items-table select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--card-background);
    color: var(--text-primary, #333);
    transition: all 0.2s ease;
  }

  .items-table input:focus,
  .items-table select:focus {
    border-color: var(--primary-color, #007ec7);
    box-shadow: 0 0 0 2px rgba(0, 126, 199, 0.1);
    outline: none;
  }

  /* Mobile-optimized item row cards */
  .item-row {
    background: var(--card-background);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
  }

  .item-row:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
  }

  .item-row td {
    border: none;
    padding: 0.75rem;
  }

  .item-description-wrapper {
    position: relative;
  }

  .item-description {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--card-background);
    color: var(--text-primary, #333);
    transition: all 0.2s ease;
  }

  .item-description:focus {
    border-color: var(--primary-color, #007ec7);
    box-shadow: 0 0 0 2px rgba(0, 126, 199, 0.1);
    outline: none;
  }

  /* Item description help text - smaller and less prominent */
  .item-description-help small {
    color: var(--text-light, #999) !important;
    font-size: 0.75rem !important;
    margin-top: 0.25rem;
    display: block;
    opacity: 0.8;
  }

  /* Mobile-optimized invoice totals */
  .invoice-totals {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border: 1px solid var(--border-color, #e0e0e0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }

  .totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--text-primary, #333);
  }

  .totals-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color, #e0e0e0);
  }

  .totals-row:last-child {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary-color, #007ec7);
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-color, #e0e0e0);
  }

  /* Mobile-optimized items pagination */
  .items-pagination {
    background: var(--card-background);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color, #e0e0e0);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }

  .pagination-info {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
    font-weight: 500;
  }

  .pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
  }

  .pagination-btn {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    background: var(--card-background);
    color: var(--text-primary, #333);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
  }

  .pagination-btn:hover:not(:disabled) {
    border-color: var(--primary-color, #007ec7);
    background: rgba(0, 126, 199, 0.05);
  }

  .pagination-btn.active {
    background: var(--primary-color, #007ec7);
    color: white;
    border-color: var(--primary-color, #007ec7);
    box-shadow: 0 2px 4px rgba(0, 126, 199, 0.2);
  }

  .pagination-btn.active:hover {
    background: var(--primary-color, #007ec7);
    transform: none;
  }

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

  .items-limit-info {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light, #999);
    font-style: italic;
  }

  /* Mobile-optimized item action buttons */
  .item-action-buttons {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
  }

  .item-action-buttons .btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
  }

  /* Ensure buttons are properly aligned on mobile */
  @media (max-width: 480px) {
    .item-action-buttons {
      flex-direction: column;
      gap: 0.5rem;
      justify-content: flex-start;
    }

    .item-action-buttons .btn {
      flex: none;
      width: 100%;
      min-width: auto;
    }
  }
}

.item-discount-value {
  display: none;
  width: 90px;
  min-width: 70px;
  max-width: 120px;
}

/* Item Action Buttons */
.item-action-buttons {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.item-action-buttons .btn {
  flex: 0 1 auto;
  min-width: 160px;
  justify-content: center;
  height: 44px;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Items Pagination Styles */
.items-pagination {
  margin-top: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pagination-info {
  text-align: center;
  margin-bottom: 10px;
  font-weight: 500;
  color: #495057;
  font-size: 0.95rem;
}

.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pagination-controls .pagination-btn {
  padding: 10px 18px;
  border: 1px solid #dee2e6;
  background: white;
  color: #495057;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pagination-controls .pagination-btn:hover:not(:disabled) {
  background: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pagination-controls .pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.pagination-controls .pagination-btn.active {
  background: #007bff;
  color: white;
  border-color: #007bff;
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
  font-weight: 600;
}

.pagination-controls .pagination-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#items-page-numbers {
  display: flex;
  gap: 5px;
}

#items-page-numbers .page-number {
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  background: white;
  color: #495057;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  min-width: 36px;
  text-align: center;
}

#items-page-numbers .page-number:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#items-page-numbers .page-number.active {
  background: #007bff;
  color: white;
  border-color: #007bff;
  font-weight: 600;
}

#items-page-numbers .page-number:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.items-limit-info {
  text-align: center;
  color: #6c757d;
  font-size: 13px;
  font-style: italic;
}

/* Hide items that are not on the current page */
.item-row.hidden {
  display: none;
}

/* Show only items on the current page */
.item-row.visible {
  display: table-row;
}

/* REMOVED: These styles are now handled in invoices.html to avoid conflicts */

/* Removed conflicting dark mode styles - now handled above */
[data-theme="dark"] .invoice-preview-container {
  background: #fff !important;
}
/* Removed conflicting dark mode styles for invoice templates */

/* Removed conflicting dark mode styles - now handled above */

@media (max-width: 768px) {
  #invoiceModal .items-table thead {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
  }
  #invoiceModal .items-table tr {
    background: #f8fafc !important;
    border-radius: 18px !important;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07) !important;
    margin-bottom: 1rem !important;
    padding: 0.7rem 2rem 1rem 2rem !important; /* much more horizontal padding */
    transition: box-shadow 0.18s, transform 0.18s;
    border: none !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  #invoiceModal .items-table tr:active,
  #invoiceModal .items-table tr:focus,
  #invoiceModal .items-table tr:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.13) !important;
    transform: translateY(-2px) scale(1.01);
  }
  #invoiceModal .items-table td {
    display: block !important;
    width: 100% !important;
    padding: 0.3rem 0.8rem !important; /* more left/right padding */
    border: none !important;
    position: relative !important;
    border-bottom: 1px solid #e5e7eb !important;
    font-size: 0.9em !important;
    margin-bottom: 0.15rem !important;
    background: transparent !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  #invoiceModal .items-table td:last-child {
    border-bottom: none !important;
  }
  #invoiceModal .items-table td:before {
    content: attr(data-label) !important;
    display: block !important;
    font-weight: 600 !important;
    color: #555 !important;
    font-size: 0.9em !important;
    margin-bottom: 2px !important;
    text-align: left !important;
    padding-left: 2px !important;
    padding-right: 2px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  #invoiceModal .items-table input,
  #invoiceModal .items-table select {
    font-size: 0.9em !important;
    margin-bottom: 0.1rem !important;
    padding: 0.35em 0.6em !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
  }
  #invoiceModal .items-table .item-total,
  #invoiceModal .items-table td:last-child .item-total {
    font-weight: bold !important;
    color: #2563eb !important;
    font-size: 1.1em !important;
    letter-spacing: 0.01em;
  }
  #invoiceModal .items-table .remove-item-btn {
    margin-top: 0.7rem !important;
    background: #fff0f0 !important;
    border: 1px solid #fca5a5 !important;
    color: #e55353 !important;
    transition: background 0.18s, box-shadow 0.18s;
    box-shadow: 0 1px 4px rgba(252, 165, 165, 0.1);
  }
  #invoiceModal .items-table .remove-item-btn:hover {
    background: #ffe4e6 !important;
    color: #b91c1c !important;
  }
}

@media (max-width: 768px) {
  [data-theme="dark"] #invoiceModal .items-table tr {
    background: #23262f !important;
    border-color: #2a2d3a !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.1) !important;
  }
  [data-theme="dark"] #invoiceModal .items-table td:before {
    color: #60a5fa !important;
  }
  [data-theme="dark"] #invoiceModal .items-table td {
    border-bottom: 1px solid #2a2d3a !important;
  }
}

@media (max-width: 768px) {
  #invoiceModal .items-table td:before {
    text-align: left !important;
  }
  #invoiceModal .items-table td:first-child,
  #invoiceModal .items-table td:first-child input {
    text-align: left !important;
    justify-content: flex-start !important;
  }
}

@media (max-width: 768px) {
  #invoiceModal .items-table td {
    display: block !important;
    width: 100% !important;
    padding: 0.4rem 0.2rem !important;
    border: none !important;
    position: relative !important;
    border-bottom: 1px solid #f0f0f0 !important;
    font-size: 0.8em !important;
    margin-bottom: 0.2rem !important;
  }
  #invoiceModal .items-table td:last-child {
    border-bottom: none !important;
  }
  #invoiceModal .items-table td:before {
    content: attr(data-label) !important;
    display: block !important;
    font-weight: 600 !important;
    color: #555 !important;
    font-size: 0.8em !important;
    margin-bottom: 2px !important;
    text-align: left !important;
    padding-right: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    word-break: break-word !important;
  }
  #invoiceModal .items-table input,
  #invoiceModal .items-table select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 0.8em !important;
    text-align: left !important;
  }
}

/* Mobile styles for invoice preview */
@media (max-width: 600px) {
  .invoice-preview-container {
    padding: 0 !important;
    font-size: 14px !important;
    height: 100%;
    overflow: auto;
  }

  #invoicePreviewContent {
    padding: 0.5rem !important;
    margin: 0 !important;
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 300px;
    overflow: auto;
  }

  .invoice-header,
  .company-info,
  .client-info,
  .invoice-info-box {
    width: 100% !important;
    box-sizing: border-box;
    margin: 0 0 8px 0 !important;
    padding: 8px !important;
    font-size: 14px !important;
    background: var(--card-background);
    border-radius: 4px;
  }

  .invoice-info-box {
    float: none !important;
    display: block !important;
    margin: 0 auto 8px auto !important;
    width: 100% !important;
    font-size: 13px !important;
    text-align: left !important;
  }

  .company-info h1,
  .company-info h2,
  .company-info h3 {
    font-size: 18px !important;
    margin-bottom: 4px !important;
  }

  .client-info {
    font-size: 13px !important;
    padding: 8px !important;
    margin-bottom: 8px !important;
  }

  /* Stack elements vertically */
  .invoice-header,
  .company-info,
  .invoice-info-box,
  .client-info {
    display: block !important;
    float: none !important;
    clear: both !important;
  }

  /* Remove excessive borders/shadows if any */
  .invoice-preview-container {
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  /* Ensure proper spacing */
  .invoice-preview-container > * {
    margin-bottom: 8px !important;
  }

  .invoice-preview-container > *:last-child {
    margin-bottom: 0 !important;
  }
}

/* Dark mode optimizations for mobile */
@media (max-width: 600px) {
  [data-theme="dark"] .modal-stepper {
    background: #2a2d3a;
  }

  [data-theme="dark"] .step-indicator {
    color: #a0a0a0;
  }

  [data-theme="dark"] .step-indicator.active {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
  }

  [data-theme="dark"] .items-table-container,
  [data-theme="dark"] .invoice-totals {
    background: #23262f;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .items-table th {
    background: #2a2d3a;
    color: #a0a0a0;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .items-table input,
  [data-theme="dark"] .items-table select,
  [data-theme="dark"] .item-description {
    background: #23262f;
    color: #fff;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .pagination-btn {
    background: #23262f;
    color: #fff;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .modal-invoice .modal-header,
  [data-theme="dark"] .modal-invoice .modal-footer {
    background: #23262f;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .form-group input,
  [data-theme="dark"] .form-group select,
  [data-theme="dark"] .form-group textarea {
    background: #181a20;
    color: #fff;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .form-group label {
    color: #e5e7eb;
  }

  /* Removed dark mode styles for totals rows during creation */

  [data-theme="dark"] .item-action-buttons .btn {
    background: #23262f;
    color: #fff;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .item-action-buttons .btn:hover {
    background: #2a2d3a;
    border-color: #60a5fa;
  }
}

/* View Invoice Modal - Improved Layout */
.modal-preview {
  z-index: 1100; /* Higher than other modals */
}

/* Email Modal should appear above the preview modal */
.modal-email {
  z-index: 1200;
}

.modal-preview .modal-content {
  width: 95%;
  max-width: 800px;
  max-height: 92vh; /* Reduced to prevent vertical scroll */
  margin: 4vh auto; /* Increased margin for better centering */
  display: flex;
  flex-direction: column;
  background: var(--card-background);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-preview .modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  background: var(--card-background);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-preview .modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary, #333);
}

.modal-preview .modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.modal-preview .modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color, #e0e0e0);
  background: var(--card-background);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

.modal-preview .modal-footer.step-footer {
  padding: 1rem 0;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.footer-action-buttons {
  display: flex;
  gap: 0.75rem;
}

/* Draft status indicator */
.draft-status {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #f0f0f0;
  color: #666;
  margin-left: 1rem;
}

[data-theme="dark"] .draft-status {
  background-color: #2a2d3a;
  color: #a0a0a0;
}

.draft-status.draft {
  background-color: #e3f2fd;
  color: #1976d2;
}

[data-theme="dark"] .draft-status.draft {
  background-color: #1a237e;
  color: #90caf9;
}

.draft-status.published {
  background-color: #e8f5e9;
  color: #2e7d32;
}

[data-theme="dark"] .draft-status.published {
  background-color: #1b5e20;
  color: #a5d6a7;
}

/* Invoice View Header - Improved Layout */
.invoice-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  background: var(--card-background);
  flex-shrink: 0;
}

.invoice-view-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.invoice-view-info h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #333);
}

.invoice-view-info .status {
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-weight: 500;
  display: inline-block;
  width: fit-content;
}

.invoice-view-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.invoice-view-actions .btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Invoice Preview Container - Improved Layout */
.invoice-preview-container {
  flex: 1;
  overflow: auto;
  background: var(--background-color, #f8f9fa);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Invoice Content Styling - Improved Readability */
#invoicePreviewContent {
  flex: 1;
  overflow: auto;
  padding: 1.5rem;
  background: var(--card-background);
  margin: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  min-height: 400px;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Invoice Header Styling */
#invoicePreviewContent .invoice-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color, #e0e0e0);
}

#invoicePreviewContent .company-info {
  margin-bottom: 1.5rem;
}

#invoicePreviewContent .company-info h1,
#invoicePreviewContent .company-info h2,
#invoicePreviewContent .company-info h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #333);
}

#invoicePreviewContent .company-info p {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: var(--text-secondary, #666);
}

/* Invoice Info Box Styling */
#invoicePreviewContent .invoice-info-box {
  background: linear-gradient(
    135deg,
    var(--primary-color, #007ec7) 0%,
    var(--primary-dark, #005a9e) 100%
  );
  color: white;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 126, 199, 0.2);
}

#invoicePreviewContent .invoice-info-box h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: white;
}

#invoicePreviewContent .invoice-info-box p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: rgba(255, 255, 255, 0.9);
}

/* Client Info Styling */
#invoicePreviewContent .client-info {
  background: var(--card-background);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

#invoicePreviewContent .client-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary, #333);
}

#invoicePreviewContent .client-info p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary, #666);
}

/* Invoice Table Styling */
#invoicePreviewContent .invoice-table,
#invoicePreviewContent .invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  background: var(--card-background);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

#invoicePreviewContent .invoice-table th,
#invoicePreviewContent .invoice-items-table th {
  background: linear-gradient(
    135deg,
    var(--primary-color, #007ec7) 0%,
    var(--primary-dark, #005a9e) 100%
  );
  color: white;
  padding: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  border: none;
}

#invoicePreviewContent .invoice-table td,
#invoicePreviewContent .invoice-items-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  font-size: 0.85rem;
  color: var(--text-primary, #333);
}

#invoicePreviewContent .invoice-table tr:last-child td,
#invoicePreviewContent .invoice-items-table tr:last-child td {
  border-bottom: none;
}

#invoicePreviewContent .invoice-table tr:hover td,
#invoicePreviewContent .invoice-items-table tr:hover td {
  background: rgba(0, 126, 199, 0.05);
}

/* Invoice Totals Styling */
#invoicePreviewContent .invoice-totals {
  background: var(--card-background);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

#invoicePreviewContent .invoice-totals .totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-primary, #333);
}

#invoicePreviewContent .invoice-totals .totals-row:not(:last-child) {
  border-bottom: 1px solid var(--border-color, #e0e0e0);
}

#invoicePreviewContent .invoice-totals .totals-row:last-child {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary-color, #007ec7);
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 2px solid var(--primary-color, #007ec7);
}

/* Notes Section Styling */
#invoicePreviewContent .invoice-notes {
  background: var(--card-background);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

#invoicePreviewContent .invoice-notes h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #333);
}

#invoicePreviewContent .invoice-notes p {
  font-size: 0.85rem;
  color: var(--text-secondary, #666);
  line-height: 1.4;
}

@media (max-width: 480px) {
  .invoice-view-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .invoice-view-actions .btn {
    width: 100%;
    justify-content: center;
  }

  #invoicePreviewContent {
    margin: 0.25rem;
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

/* Dark Mode Support for Invoice Preview */
@media (max-width: 600px) {
  [data-theme="dark"] .modal-preview .modal-content {
    background: #23262f;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .modal-preview .modal-header,
  [data-theme="dark"] .modal-preview .modal-footer {
    background: #23262f;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .modal-preview .modal-header h2 {
    color: #fff;
  }

  [data-theme="dark"] .invoice-view-header {
    background: #23262f;
    border-color: #2a2d3a;
  }

  [data-theme="dark"] .invoice-view-info h3 {
    color: #fff;
  }

  [data-theme="dark"] .invoice-view-info .status {
    background: #2a2d3a;
    color: #a0a0a0;
  }

  [data-theme="dark"] .invoice-preview-container {
    background: #1a1d24;
  }

  /* Removed conflicting dark mode styles for invoice templates */
}

/* Mobile Optimizations for Invoice Preview */
@media (max-width: 768px) {
  .modal-preview .modal-content {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .modal-preview .modal-header {
    padding: 1rem;
  }

  .modal-preview .modal-header h2 {
    font-size: 1.1rem;
  }

  .invoice-view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }

  .invoice-view-info {
    width: 100%;
  }

  .invoice-view-info h3 {
    font-size: 1rem;
  }

  .invoice-view-actions {
    width: 100%;
    justify-content: space-between;
  }

  .invoice-view-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
  }

  #invoicePreviewContent {
    margin: 0.5rem;
    padding: 1rem;
    min-height: 300px;
    font-size: 0.9rem;
  }

  /* Mobile Invoice Content Improvements */
  #invoicePreviewContent .company-info h1,
  #invoicePreviewContent .company-info h2,
  #invoicePreviewContent .company-info h3 {
    font-size: 1.2rem;
  }

  #invoicePreviewContent .company-info p {
    font-size: 0.85rem;
  }

  #invoicePreviewContent .invoice-info-box {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  #invoicePreviewContent .invoice-info-box h3 {
    font-size: 1rem;
  }

  #invoicePreviewContent .invoice-info-box p {
    font-size: 0.8rem;
  }

  #invoicePreviewContent .client-info {
    padding: 0.75rem;
    margin-bottom: 1rem;
  }

  #invoicePreviewContent .client-info h3 {
    font-size: 1rem;
  }

  #invoicePreviewContent .client-info p {
    font-size: 0.8rem;
  }

  #invoicePreviewContent .invoice-table th,
  #invoicePreviewContent .invoice-items-table th {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  #invoicePreviewContent .invoice-table td,
  #invoicePreviewContent .invoice-items-table td {
    padding: 0.5rem;
    font-size: 0.75rem;
  }

  #invoicePreviewContent .invoice-totals {
    padding: 0.75rem;
  }

  #invoicePreviewContent .invoice-totals .totals-row {
    font-size: 0.8rem;
  }

  #invoicePreviewContent .invoice-totals .totals-row:last-child {
    font-size: 1rem;
  }

  .modal-preview .modal-footer {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .invoice-view-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .invoice-view-actions .btn {
    width: 100%;
    justify-content: center;
  }

  #invoicePreviewContent {
    margin: 0.25rem;
    padding: 0.75rem;
    font-size: 0.85rem;
  }

  /* Extra Small Screen Invoice Content */
  #invoicePreviewContent .company-info h1,
  #invoicePreviewContent .company-info h2,
  #invoicePreviewContent .company-info h3 {
    font-size: 1.1rem;
  }

  #invoicePreviewContent .company-info p {
    font-size: 0.8rem;
  }

  #invoicePreviewContent .invoice-info-box {
    padding: 0.5rem;
  }

  #invoicePreviewContent .invoice-info-box h3 {
    font-size: 0.9rem;
  }

  #invoicePreviewContent .invoice-info-box p {
    font-size: 0.75rem;
  }

  #invoicePreviewContent .client-info {
    padding: 0.5rem;
  }

  #invoicePreviewContent .client-info h3 {
    font-size: 0.9rem;
  }

  #invoicePreviewContent .client-info p {
    font-size: 0.75rem;
  }

  #invoicePreviewContent .invoice-table th,
  #invoicePreviewContent .invoice-items-table th {
    padding: 0.4rem;
    font-size: 0.7rem;
  }

  #invoicePreviewContent .invoice-table td,
  #invoicePreviewContent .invoice-items-table td {
    padding: 0.4rem;
    font-size: 0.7rem;
  }

  #invoicePreviewContent .invoice-totals {
    padding: 0.5rem;
  }

  #invoicePreviewContent .invoice-totals .totals-row {
    font-size: 0.75rem;
  }

  #invoicePreviewContent .invoice-totals .totals-row:last-child {
    font-size: 0.9rem;
  }
}

/* Dark Mode Support for Invoice Content */
@media (max-width: 600px) {
  /* Removed conflicting dark mode styles for invoice preview content */
}

/* Hide add product hint in desktop mode */
@media (min-width: 769px) {
  .item-description-help {
    display: none !important;
  }
}

/* Dark mode should NOT affect invoice templates - ONLY for preview */
[data-theme="dark"] #invoicePreviewContent {
  background: #fff !important;
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .company-info h1,
[data-theme="dark"] #invoicePreviewContent .company-info h2,
[data-theme="dark"] #invoicePreviewContent .company-info h3 {
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .company-info p {
  color: #555 !important;
}

[data-theme="dark"] #invoicePreviewContent .client-info {
  background: #fff !important;
  border-color: #e0e0e0 !important;
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .client-info h3 {
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .client-info p {
  color: #555 !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-table,
[data-theme="dark"] #invoicePreviewContent .invoice-items-table {
  background: #fff !important;
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-table th,
[data-theme="dark"] #invoicePreviewContent .invoice-items-table th {
  background: linear-gradient(135deg, #007ec7 0%, #005a9e 100%) !important;
  color: white !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-table td,
[data-theme="dark"] #invoicePreviewContent .invoice-items-table td {
  color: #222 !important;
  border-color: #e0e0e0 !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-table tr:hover td,
[data-theme="dark"] #invoicePreviewContent .invoice-items-table tr:hover td {
  background: rgba(0, 126, 199, 0.05) !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-totals {
  background: #fff !important;
  border-color: #e0e0e0 !important;
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-totals .totals-row {
  color: #222 !important;
  border-color: #e0e0e0 !important;
}

[data-theme="dark"]
  #invoicePreviewContent
  .invoice-totals
  .totals-row:last-child {
  color: var(--primary-color, #007ec7) !important;
  border-top-color: var(--primary-color, #007ec7) !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-notes {
  background: #fff !important;
  border-color: #e0e0e0 !important;
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-notes h3 {
  color: #222 !important;
}

[data-theme="dark"] #invoicePreviewContent .invoice-notes p {
  color: #555 !important;
}

/* Dark mode for invoice creation interface - keep dark */
[data-theme="dark"] .modal-invoice .invoice-totals {
  background: #181a20 !important;
  color: #fff !important;
  border-radius: 8px !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .review-section {
  background: #181a20 !important;
  color: #fff !important;
  border-radius: 8px !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .totals-row:not(#invoicePreviewContent .totals-row) {
  color: #fff !important;
}

[data-theme="dark"]
  .totals-row:not(#invoicePreviewContent .totals-row):last-child {
  color: #60a5fa !important;
}

/* Dark mode for invoice creation modal */
[data-theme="dark"] .modal-content {
  background: #23262f !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .modal-header {
  background: #23262f !important;
  border-bottom: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .modal-header h2 {
  color: #fff !important;
}

[data-theme="dark"] .modal-body {
  background: #23262f !important;
  color: #fff !important;
}

[data-theme="dark"] .modal-footer {
  background: #23262f !important;
  border-top: 1px solid #2a2d3a !important;
}

/* Dark mode for items table in creation */
[data-theme="dark"] .items-table-container {
  background: #23262f !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

[data-theme="dark"] .items-table th,
[data-theme="dark"] .items-table td {
  background: #23262f !important;
  color: #fff !important;
  border-bottom: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .items-table tr {
  border-bottom: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .items-table input,
[data-theme="dark"] .items-table select,
[data-theme="dark"] .items-table textarea {
  background: #181a20 !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
}

/* Dark mode for pagination in creation */
[data-theme="dark"] .items-pagination {
  background: #181a20 !important;
  color: #fff !important;
  border-radius: 8px !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .pagination-controls .pagination-btn {
  background: #23262f !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .pagination-controls .pagination-btn.active {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

[data-theme="dark"] .pagination-controls .pagination-btn:disabled {
  background: #23262f !important;
  color: #555 !important;
  opacity: 0.5;
}

/* Dark mode for suggestions in creation */
[data-theme="dark"] .suggestion-box,
[data-theme="dark"] .product-suggestions {
  background: #23262f !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
  box-shadow: 0 2px 8px #181a20 !important;
}

[data-theme="dark"] .suggestion-item,
[data-theme="dark"] .product-suggestions .suggestion-item {
  background: #23262f !important;
  color: #fff !important;
  border-bottom: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .suggestion-item:hover,
[data-theme="dark"] .product-suggestions .suggestion-item:hover {
  background: #2563eb !important;
  color: #fff !important;
}

[data-theme="dark"] .product-suggestions .suggestion-item .product-price {
  color: #60a5fa !important;
}

[data-theme="dark"] .suggestion-item:last-child,
[data-theme="dark"] .product-suggestions .suggestion-item:last-child {
  border-bottom: none !important;
}

/* Dark mode for form elements in creation */
[data-theme="dark"] .form-group label {
  color: #e5e7eb !important;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: #181a20 !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2) !important;
}

[data-theme="dark"] .form-group input:disabled,
[data-theme="dark"] .form-group select:disabled,
[data-theme="dark"] .form-group textarea:disabled {
  background: #2a2d3a !important;
  color: #6b7280 !important;
}

/* Dark mode for buttons in creation */
[data-theme="dark"] .btn {
  background: #23262f !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .btn:hover {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

/* Dark mode for stepper in creation */
[data-theme="dark"] .modal-stepper .step-indicator {
  background: #2a2d3a !important;
  color: #6b7280 !important;
}

[data-theme="dark"] .modal-stepper .step-indicator.active {
  background: #2563eb !important;
  color: #fff !important;
}

[data-theme="dark"] .modal-stepper .step-indicator:not(.active) {
  background: #2a2d3a !important;
  color: #6b7280 !important;
}

/* Dark mode for overlay - removed duplicate, using lighter overlay from line 1785 */

/* Dark mode for dropdowns in creation */
[data-theme="dark"] .action-dropdown {
  background: #23262f !important;
  border: 1px solid #2a2d3a !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .dropdown-header {
  background: #181a20 !important;
  color: #fff !important;
  border-bottom: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .dropdown-item {
  color: #fff !important;
}

[data-theme="dark"] .dropdown-item:hover {
  background: #2563eb !important;
  color: #fff !important;
}

[data-theme="dark"] .dropdown-item i {
  color: #6b7280 !important;
}

[data-theme="dark"] .dropdown-item-danger {
  color: #ef4444 !important;
}

[data-theme="dark"] .dropdown-item-danger:hover {
  background: #dc2626 !important;
  color: #fff !important;
}

[data-theme="dark"] .dropdown-item-danger i {
  color: #ef4444 !important;
}

/* Dark mode for scrollbars */
[data-theme="dark"] ::-webkit-scrollbar {
  background: #23262f !important;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #4b5563 !important;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #6b7280 !important;
}

[data-theme="dark"] ::-webkit-scrollbar-corner {
  background: #23262f !important;
}

/* Dark mode for table filters */
[data-theme="dark"] .table-filters label {
  color: #e5e7eb !important;
}

[data-theme="dark"] .table-filters select,
[data-theme="dark"] .table-filters input,
[data-theme="dark"] .search-input {
  background: #23262f !important;
  color: #fff !important;
  border: 1px solid #2a2d3a !important;
}

[data-theme="dark"] .table-filters button,
[data-theme="dark"] .search-clear-btn {
  background: #23262f !important;
  color: #fff !important;
  border: 1px solid #2563eb !important;
  transition: background 0.2s, color 0.2s, border 0.2s;
}

[data-theme="dark"] .table-filters button:hover,
[data-theme="dark"] .search-clear-btn:hover {
  background: #2563eb !important;
  color: #fff !important;
  border-color: #2563eb !important;
}

[data-theme="dark"] .table-filters,
[data-theme="dark"] .search-bar {
  background: #23262f !important;
}

/* Review Step Styles */
.review-summary {
  max-height: 400px;
  overflow-y: auto;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.review-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e9ecef;
}

.review-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.review-section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #007ec7;
}

.review-section p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.review-section p strong {
  color: #555;
  font-weight: 600;
}

.review-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.review-items-table th {
  background-color: #f8f9fa;
  padding: 0.5rem;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #dee2e6;
}

.review-items-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #e9ecef;
  vertical-align: top;
}

.review-items-table tbody tr:hover {
  background-color: #f8f9fa;
}

.review-totals {
  background: #fff;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #e9ecef;
  margin-top: 1rem;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  font-size: 0.9rem;
}

.total-row:not(:last-child) {
  border-bottom: 1px solid #f0f0f0;
}

.total-row.total-final {
  font-weight: 600;
  font-size: 1rem;
  color: #007ec7;
  border-top: 2px solid #007ec7;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

/* Dark theme support for review step */
[data-theme="dark"] .review-summary {
  background: #2d3748;
  border-color: #4a5568;
}

[data-theme="dark"] .review-section h4 {
  color: #e2e8f0;
  border-bottom-color: #007ec7;
}

[data-theme="dark"] .review-section p {
  color: #cbd5e0;
}

[data-theme="dark"] .review-section p strong {
  color: #e2e8f0;
}

[data-theme="dark"] .review-items-table th {
  background-color: #4a5568;
  color: #e2e8f0;
  border-bottom-color: #718096;
}

[data-theme="dark"] .review-items-table td {
  color: #cbd5e0;
  border-bottom-color: #4a5568;
}

[data-theme="dark"] .review-items-table tbody tr:hover {
  background-color: #4a5568;
}

[data-theme="dark"] .review-totals {
  background: #2d3748;
  border-color: #4a5568;
}

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

[data-theme="dark"] .total-row:not(:last-child) {
  border-bottom-color: #4a5568;
}

[data-theme="dark"] .total-row.total-final {
  color: #007ec7;
  border-top-color: #007ec7;
}

/* Additional styles for the old implementation look */
.items-table-container {
  margin-top: 12px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th {
  background-color: #f8f9fa;
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  color: #495057;
}

.items-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #dee2e6;
  vertical-align: top;
}

.invoice-totals {
  margin-top: 16px;
  text-align: right;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.totals-row span:first-child {
  font-weight: 500;
}

.totals-row span:last-child {
  font-weight: 600;
}

/* Dark theme support for the old implementation */
[data-theme="dark"] .items-table th {
  background-color: #2d3748;
  color: #e2e8f0;
  border-bottom-color: #4a5568;
}

[data-theme="dark"] .items-table td {
  color: #e2e8f0;
  border-bottom-color: #4a5568;
}

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

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

/* Comprehensive Dark Mode Status Styles for Invoice Management */
[data-theme="dark"] .status {
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 500;
  backdrop-filter: blur(4px);
}

[data-theme="dark"] .status i {
  margin-right: 6px;
  opacity: 0.9;
}

[data-theme="dark"] .status.gray {
  background-color: rgba(156, 163, 175, 0.15);
  color: #9ca3af;
  border-color: rgba(156, 163, 175, 0.3);
}

[data-theme="dark"] .status.blue {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .status.orange {
  background-color: rgba(234, 88, 12, 0.15);
  color: #f97316;
  border-color: rgba(234, 88, 12, 0.3);
}

[data-theme="dark"] .status.green {
  background-color: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .status.red {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Dark Mode Status Timeline */
[data-theme="dark"] .status-timeline {
  background: #1a1d24;
  border: 1px solid #2a2d3a;
}

[data-theme="dark"] .timeline-marker {
  background: #4a5568;
}

[data-theme="dark"] .timeline-item.active .timeline-marker {
  background: var(--primary-color);
}

[data-theme="dark"] .timeline-date {
  color: #9ca3af;
}

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

/* Dark Mode Status Action Buttons */
[data-theme="dark"] .status-actions button {
  background: #2a2d3a;
  color: #e2e8f0;
  border: 1px solid #4a5568;
}

[data-theme="dark"] .status-actions button:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Dark Mode Invoice View Header Status */
[data-theme="dark"] .invoice-view-header .status {
  background: #2a2d3a;
  color: #e2e8f0;
  border: 1px solid #4a5568;
}

[data-theme="dark"] .invoice-view-info .status {
  background: #2a2d3a;
  color: #e2e8f0;
  border: 1px solid #4a5568;
}

/* Dark Mode Payment Information */
[data-theme="dark"] .payment-info-small {
  color: #9ca3af !important;
}

[data-theme="dark"] .payment-row {
  color: #d1d5db !important;
}

[data-theme="dark"] .progress-bar-small {
  background: rgba(156, 163, 175, 0.2) !important;
}

[data-theme="dark"] .progress-fill {
  background: #60a5fa !important;
}

/* Dark Mode Status Badge Enhancements */
[data-theme="dark"] .status-badge {
  background: #2a2d3a !important;
  color: #e2e8f0 !important;
  border: 1px solid #4a5568 !important;
}

[data-theme="dark"] .status-badge.status-paid {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #22c55e !important;
  border-color: rgba(34, 197, 94, 0.3) !important;
}

[data-theme="dark"] .status-badge.status-pending {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #60a5fa !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-theme="dark"] .status-badge.status-overdue {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

[data-theme="dark"] .status-badge.status-partially_paid {
  background: rgba(234, 88, 12, 0.15) !important;
  color: #f97316 !important;
  border-color: rgba(234, 88, 12, 0.3) !important;
}

[data-theme="dark"] .status-badge.status-draft {
  background: rgba(156, 163, 175, 0.15) !important;
  color: #9ca3af !important;
  border-color: rgba(156, 163, 175, 0.3) !important;
}

/* Enhanced Invoice Modal Improvements */
/* Fixes for review step visibility and modal behavior */

/* Ensure modal content is properly contained */
.modal-invoice .modal-content {
  display: flex;
  flex-direction: column;
  max-height: 92vh; /* Reduced from 95vh to prevent vertical scroll */
  overflow: hidden;
}

.modal-invoice .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  background: var(--card-background, #ffffff);
}

/* Enhanced review step visibility */
.step-4 {
  min-height: auto;
}

.step-4 .review-section {
  background: var(--card-background, #ffffff);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color, #e0e0e0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.step-4 #invoiceReviewSummary {
  background: var(--background-color, #f8f9fa);
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--border-color, #e0e0e0);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 1rem;
}

.step-4 #invoiceReviewSummary h4 {
  color: var(--primary-color, #007ec7);
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.step-4 #invoiceReviewSummary p {
  margin-bottom: 0.5rem;
  color: var(--text-primary, #333);
}

/* Ensure step footer is always visible in review step */
.step-4 .step-footer {
  position: sticky;
  bottom: 0;
  background: var(--card-background, #ffffff);
  border-top: 1px solid var(--border-color, #e0e0e0);
  margin: 1.5rem -1.5rem -1.5rem -1.5rem;
  padding: 1.5rem;
  border-radius: 0 0 12px 12px;
  z-index: 10;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Dark mode enhancements for review step */
[data-theme="dark"] .step-4 .review-section {
  background: #23262f;
  border-color: #2a2d3a;
}

[data-theme="dark"] .step-4 #invoiceReviewSummary {
  background: #181a20;
  border-color: #2a2d3a;
  color: #e5e7eb;
}

[data-theme="dark"] .step-4 .step-footer {
  background: #23262f;
  border-color: #2a2d3a;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.35);
}

/* Mobile optimizations for review step */
@media (max-width: 768px) {
  .step-4 .review-section {
    padding: 1rem;
    margin: 1rem 0;
  }

  .step-4 #invoiceReviewSummary {
    padding: 1rem;
    margin-top: 0.75rem;
  }

  .step-4 .step-footer {
    padding: 1rem;
    margin: 1rem -1rem -1rem -1rem;
    border-radius: 0 0 12px 12px;
  }
}

@media (max-width: 480px) {
  .step-4 .review-section {
    padding: 0.75rem;
    margin: 0.75rem 0;
  }

  .step-4 #invoiceReviewSummary {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .step-4 .step-footer {
    padding: 0.75rem;
    margin: 0.75rem -0.75rem -0.75rem -0.75rem;
  }
}

/* Ensure proper spacing in review step */
.step-4 h3 {
  margin-bottom: 1.5rem;
  color: var(--text-primary, #333);
  font-size: 1.1rem;
  font-weight: 600;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-color, #007ec7);
}

.step-4 .form-group {
  margin-bottom: 1.5rem;
}

.step-4 .form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary, #333);
  font-size: 0.9rem;
}

.step-4 .form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 8px;
  background: var(--card-background, #ffffff);
  color: var(--text-primary, #333);
  font-size: 16px;
  transition: all 0.2s ease;
  min-height: 80px;
  resize: vertical;
  box-sizing: border-box;
}

.step-4 .form-group textarea:focus {
  border-color: var(--primary-color, #007ec7);
  box-shadow: 0 0 0 3px rgba(0, 126, 199, 0.1);
  outline: none;
}

/* Enhanced modal stepper for better visibility */
.modal-invoice .modal-stepper {
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: 1px solid #e0e0e0;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
}

.modal-invoice .step-indicator {
  flex: 1;
  padding: 0.75rem 0.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #666;
  background: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  transition: all 0.3s ease;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.modal-invoice .step-indicator:last-child {
  border-right: none;
}

.modal-invoice .step-indicator.active {
  background: #007ec7;
  color: white;
  box-shadow: 0 2px 6px rgba(0, 126, 199, 0.25);
}

.modal-invoice .step-indicator.completed {
  background: var(--success-color, #10b981);
  color: white;
}

/* Exchange rate display styling */
.exchange-rate-display:not(.fx-rate-card) {
  margin-top: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 0.9em;
  color: #1a1a1a;
  border-left: 3px solid #007ec7;
}

/* Preview button styling */
.preview-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-btn:hover {
  background: #218838;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.preview-action-section {
  text-align: center;
  margin: 1.5rem 0;
}

.eye-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z'/%3E%3C/svg%3E")
    no-repeat center;
  mask-size: contain;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z'/%3E%3C/svg%3E")
    no-repeat center;
  -webkit-mask-size: contain;
}

.exchange-rate-display:not(.fx-rate-card) .rate-row {
  margin: 2px 0;
  line-height: 1.4;
}

.exchange-rate-display:not(.fx-rate-card) .rate-row.small {
  font-size: 0.85em;
  color: #777;
  font-style: italic;
}

/* Dark mode stepper enhancements */
[data-theme="dark"] .modal-invoice .modal-stepper {
  background: #181a20;
  border-color: #2a2d3a;
}

[data-theme="dark"] .modal-invoice .step-indicator {
  background: #181a20;
  color: #a0a0a0;
  border-color: #2a2d3a;
}

[data-theme="dark"] .modal-invoice .step-indicator.active {
  background: #2563eb;
  color: #ffffff;
}

[data-theme="dark"] .modal-invoice .step-indicator.completed {
  background: #059669;
  color: #ffffff;
}

/* Dark mode exchange rate display */
[data-theme="dark"] .exchange-rate-display:not(.fx-rate-card) {
  background: #2a2d3a;
  color: #e0e0e0;
  border-left-color: #3b82f6;
}

