/* ═══════════════════════════════════════════════════════════════
   TechBugs — Invoice / Document Styles v2.0
   ═══════════════════════════════════════════════════════════════ */

/* ── Filters Bar ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 22px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  flex-wrap: wrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: fadeInUp 0.45s var(--ease-out) both;
  position: relative;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'Inter', sans-serif;
}

.filter-group select,
.filter-group input {
  padding: 9px 14px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #FFFFFF;
  outline: none;
  font-family: inherit;
  transition: all var(--duration-fast);
}

.filter-group select:hover,
.filter-group input:hover {
  border-color: #44444c;
  background: #1f1f23;
}

.filter-group select:focus,
.filter-group input:focus {
  background: #18181b;
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 59, 45, 0.2);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.filter-btn:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}

/* ── Card ── */
.invoices-card {
  background: #141416;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  animation: fadeInUp 0.5s var(--ease-out) both;
  animation-delay: 0.1s;
}

.header-actions { display: flex; gap: 10px; }

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: #18181b;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.export-btn:hover {
  background: #27272a;
  border-color: #3f3f46;
  color: #FFFFFF;
  box-shadow: none;
  transform: translateY(-1px);
}

/* ── Table ── */
.table-container { overflow-x: auto; }

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

.invoices-table th,
.invoices-table td {
  padding: 14px 20px;
  text-align: left;
}

.invoices-table th {
  background: #18181b;
  font-size: 11px;
  font-weight: 700;
  color: #a5a5b8;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: 'Inter', sans-serif;
}

.invoices-table tbody tr {
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: all var(--duration-fast);
}

.invoices-table tbody tr:last-child {
  border-bottom: none;
}

.invoices-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.015);
}

.invoices-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
  box-shadow: none;
}

.invoices-table td { font-size: 13px; color: var(--text-secondary); }

.invoices-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.invoice-id {
  font-weight: 700;
  color: #ef4444;
  letter-spacing: 0.02em;
}

.customer-name { font-weight: 600; color: #FFFFFF; }
.amount { font-weight: 700; color: #FFFFFF; }

/* ── Action Buttons ── */
.action-buttons { display: flex; gap: 8px; }

.action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #18181b;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
  color: var(--text-secondary);
  font-size: 13px;
}

.action-btn.view { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.25); color: #60a5fa; }
.action-btn.view:hover { background: #3b82f6; border-color: #3b82f6; color: white; transform: translateY(-2px); box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4); }

.action-btn.edit { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.25); color: #fbbf24; }
.action-btn.edit:hover { background: #f59e0b; border-color: #f59e0b; color: white; transform: translateY(-2px); box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4); }

.action-btn.delete { background: rgba(220, 38, 38, 0.1); border-color: rgba(220, 38, 38, 0.25); color: #ef4444; }
.action-btn.delete:hover { background: #dc2626; border-color: #dc2626; color: white; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }

/* ── Table Footer ── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: none;
  background: #141416;
}

.showing-count { font-size: 12px; color: var(--text-tertiary); }
.showing-count strong { color: #FFFFFF; }

.pagination { display: flex; gap: 6px; }

.page-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: #18181b;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
  font-size: 12px;
  font-weight: 600;
}

.page-btn:hover:not(:disabled) {
  background: #27272a;
  border-color: #3f3f46;
  color: #FFFFFF;
}

.page-btn.active {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.3);
}
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════════
   MODAL VARIANTS
   ═══════════════════════════════════════════════════════════════ */

.invoice-modal {
  max-width: 980px;
  max-height: 90vh;
  overflow-y: auto;
  background: #141416;
  border: 1px solid var(--border);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8);
  border-radius: var(--radius-xl);
  position: relative;
}

.invoice-modal::before {
  display: none;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'Inter', sans-serif;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 13px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #FFFFFF;
  transition: all var(--duration-fast);
  outline: none;
  font-family: inherit;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: #44444c;
  background: #1f1f23;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  background: #18181b;
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 59, 45, 0.2);
}

.form-group textarea { min-height: 70px; resize: vertical; }

/* ── Items Section ── */
.items-section {
  margin: 18px 0 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.items-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.items-section-header h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.items-header {
  display: grid;
  grid-template-columns: 1.5fr 1.8fr 0.6fr 0.8fr 0.9fr 1fr 40px;
  gap: 8px;
  padding: 8px 12px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
}

.items-header span {
  font-size: 10px;
  font-weight: 700;
  color: #828292;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.item-row {
  display: grid;
  grid-template-columns: 1.5fr 1.8fr 0.6fr 0.8fr 0.9fr 1fr 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
}

.item-row input,
.item-row select,
.item-row textarea {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #FFFFFF;
  outline: none;
  transition: border-color var(--duration-fast);
}

.item-row input:focus,
.item-row select:focus,
.item-row textarea:focus {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.item-row .remove-item {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #8e8e9f;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
  font-size: 13px;
  box-sizing: border-box;
  justify-self: center;
  flex-shrink: 0;
}

.item-row .remove-item:hover {
  background: #dc2626;
  color: white;
  border-color: #dc2626;
}

/* ── Custom Select / Dropdown ── */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-wrapper.disabled {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #FFFFFF;
  cursor: pointer;
  transition: all var(--duration-fast);
  user-select: none;
  min-height: 40px;
  box-sizing: border-box;
}

.custom-select-trigger:hover {
  border-color: #44444c;
  background: #1f1f24;
}

.custom-select-wrapper.open .custom-select-trigger {
  border-color: #ef4444;
  background: #1c1c21;
  box-shadow: 0 0 0 2px rgba(239, 59, 45, 0.2);
}

.custom-select-trigger .trigger-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.custom-select-trigger .trigger-text.placeholder {
  color: #71717a;
}

.custom-select-trigger .trigger-arrow {
  font-size: 11px;
  color: #888899;
  transition: transform var(--duration-fast);
  margin-left: 8px;
}

.custom-select-wrapper.open .trigger-arrow {
  transform: rotate(180deg);
  color: #FFFFFF;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #1f1f24;
  border: 1px solid #36363d;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1050;
  display: none;
  flex-direction: column;
  overflow: hidden;
  padding: 4px 0;
}

.custom-select-wrapper.open .custom-select-menu {
  display: flex;
}

.custom-select-search {
  padding: 8px 10px;
  border-bottom: 1px solid #2a2a30;
  background: #18181b;
}

.custom-select-search input {
  width: 100%;
  padding: 7px 10px;
  background: #24242a;
  border: 1px solid #36363d;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 12px;
  outline: none;
  box-sizing: border-box;
}

.custom-select-search input:focus {
  border-color: #ef4444;
}

.custom-select-options {
  overflow-y: auto;
  max-height: 200px;
  padding: 2px 0;
}

.custom-select-option {
  padding: 9px 14px;
  font-size: 13.5px;
  color: #e4e4e7;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--duration-fast);
}

.custom-select-option:hover {
  background: #2a2a32;
  color: #fff;
}

.custom-select-option.selected {
  background: #2E1412;
  color: #EF3B2D;
  border-left: 3px solid #EF3B2D;
  font-weight: 600;
}

.custom-select-option.selected:hover {
  background: #361a17;
  color: #ffffff;
}

.custom-select-option .opt-phone {
  font-size: 11px;
  color: #71717a;
}

.custom-select-option:hover .opt-phone {
  color: #a1a1aa;
}

.custom-select-footer {
  border-top: 1px solid #2a2a30;
  padding: 6px 8px;
  background: #18181b;
}

.custom-select-add-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: #24242a;
  border: 1px dashed #3f3f48;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast);
  font-family: 'Space Grotesk', sans-serif;
}

.custom-select-add-btn:hover {
  background: #2c2c34;
  color: white;
  border-color: #ef4444;
}

.filter-group .custom-select-wrapper {
  min-width: 150px;
  width: auto;
}

.add-item-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--duration-fast);
  font-family: 'Space Grotesk', sans-serif;
  margin-top: 6px;
}

.add-item-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: #FFFFFF;
}

/* ═══════════════════════════════════════════════════════════════
   BALANCED BOTTOM SECTION (Documentation + Calculation Layout)
   ═══════════════════════════════════════════════════════════════ */

.modal-bottom-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-top: 14px;
}

/* Left: Documentation (Notes & Terms) */
.bottom-left-docs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bottom-left-docs .doc-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.bottom-left-docs .doc-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.bottom-left-docs .doc-label-row label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 0;
}

.bottom-left-docs .doc-hint {
  font-size: 10px;
  color: var(--text-ghost);
  font-weight: 500;
}

.bottom-left-docs textarea {
  width: 100%;
  min-height: 56px;
  height: 58px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: #FFFFFF;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
}

.bottom-left-docs textarea:focus {
  border-color: rgba(255, 255, 255, 0.28);
}

/* Right: Financial Summary Card (Matches Height of Left Column) */
.bottom-right-summary {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  height: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.summary-card-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
}

.summary-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.summary-val {
  color: #FFFFFF;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

.discount-inline-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

.discount-pct-group {
  display: flex;
  align-items: center;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  padding: 0 6px;
}

.discount-pct-group input#discountPercent {
  width: 44px;
  padding: 4px 2px;
  background: transparent;
  border: none;
  outline: none;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.discount-pct-group .pct-sign {
  font-size: 11px;
  color: var(--text-ghost);
  font-weight: 600;
  margin-left: 2px;
}

.eq-symbol {
  color: var(--text-ghost);
  font-size: 11px;
}

.discount-val-input {
  width: 74px;
  padding: 5px 8px;
  background: #18181b;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  text-align: right;
  outline: none;
}

.summary-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: auto 0 12px 0;
}

.total-row {
  padding-top: 6px;
  padding-bottom: 4px;
}

.grand-label {
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
}

.grand-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  font-family: 'Space Grotesk', sans-serif;
}

/* Modal Form Actions Bar */
.modal-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-form-actions .btn-cancel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.modal-form-actions .btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

.action-buttons-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-draft {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-draft:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

.btn-save-primary {
  background: var(--accent);
  border: none;
  color: #FFFFFF;
  padding: 9px 24px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--duration-fast);
  box-shadow: 0 4px 16px rgba(229, 9, 20, 0.35);
}

.btn-save-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(229, 9, 20, 0.45);
}

.btn-whatsapp-send {
  background: #25D366;
  border: 1px solid #20ba5a;
  color: #FFFFFF;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all var(--duration-fast);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
  white-space: nowrap;
}

.btn-whatsapp-send:hover {
  background: #20ba5a;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
}

.preview-btn.whatsapp {
  background: rgba(37, 211, 102, 0.15) !important;
  color: #22c55e !important;
  border: 1px solid rgba(37, 211, 102, 0.35) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  transition: all var(--duration-fast) !important;
}

.preview-btn.whatsapp:hover {
  background: #25D366 !important;
  color: #FFFFFF !important;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35) !important;
}

.action-btn.whatsapp {
  color: #22c55e !important;
}

.action-btn.whatsapp:hover {
  background: rgba(37, 211, 102, 0.15) !important;
  border-color: rgba(37, 211, 102, 0.35) !important;
}

/* Fallback / Legacy classes retained for compatibility */
.totals-section {
  margin-left: auto;
  width: 300px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.totals-row:last-child { border-bottom: none; }
.totals-row span:first-child { font-size: 13px; color: var(--text-secondary); }

.totals-row.total {
  padding-top: 12px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.totals-row.total span {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Space Grotesk', sans-serif;
}

.discount-input { display: flex; align-items: center; gap: 6px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: none;
}

.btn-secondary {
  padding: 9px 20px;
  background: #18181b;
  color: #e4e4e7;
  border: 1px solid #2e2e34;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
}

.btn-secondary:hover {
  background: #24242a;
  border-color: #3f3f48;
  color: #FFFFFF;
  box-shadow: none;
  transform: translateY(-1px);
}

.btn-primary {
  padding: 10px 22px;
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  position: relative;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
}

.btn-primary:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}

/* ═══════════════════════════════════════════════════════════════
   INVOICE PREVIEW / DOCUMENT SHEET
   ═══════════════════════════════════════════════════════════════ */

.invoice-preview-modal {
  max-width: 1040px;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  background: #141416;
  border: 1px solid var(--border);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8);
  border-radius: var(--radius-xl);
}

/* Fix Preview Modal Header */
.invoice-preview-modal .modal-header {
  padding: 18px 28px;
  background: #141416;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: none;
  position: relative;
  width: 100%;
}

.invoice-preview-modal .modal-header h2 {
  width: auto;
  text-align: left;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.invoice-preview-modal .preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* Dedicated Preview Action Buttons */
.preview-btn {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  padding: 9px 20px !important;
  height: 40px !important;
  background: #18181b !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  font-family: 'Space Grotesk', sans-serif !important;
  cursor: pointer !important;
  transition: all var(--duration-fast) !important;
  white-space: nowrap !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

.preview-btn:hover {
  background: #27272a !important;
  border-color: #3f3f46 !important;
  color: #FFFFFF !important;
  transform: translateY(-1px) !important;
  box-shadow: none !important;
}

.preview-btn.primary {
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25) !important;
}

.preview-btn.primary:hover {
  background: #b91c1c !important;
  border-color: #b91c1c !important;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35) !important;
  transform: translateY(-1px) !important;
}

.invoice-preview-modal .close-btn {
  position: static !important;
  transform: none !important;
  margin-left: 4px !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: var(--radius-sm) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #18181b !important;
  border: 1px solid var(--border) !important;
  color: var(--text-secondary) !important;
  font-size: 20px !important;
  cursor: pointer !important;
  transition: all var(--duration-fast) !important;
}

.invoice-preview-modal .close-btn:hover {
  background: #27272a !important;
  border-color: #3f3f46 !important;
  color: #ffffff !important;
  transform: scale(1.05) !important;
  box-shadow: none !important;
}

.invoice-preview {
  background: #ffffff;
  padding: 44px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: calc(95vh - 120px);
  overflow-y: auto;
  color: #1f2937;
}

.invoice-print { max-width: 820px; margin: 0 auto; }

.invoice-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
  padding: 24px 28px 20px;
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%) !important;
  border-radius: var(--radius);
  color: #ffffff !important;
  box-shadow: 0 4px 18px rgba(220, 38, 38, 0.2);
  border-bottom: none !important;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.brand-entity {
  display: flex;
  align-items: center;
  gap: 18px;
}

.company-logo {
  width: 76px;
  height: 76px;
  max-width: 80px;
  max-height: 80px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.35));
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.brand-title {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff !important;
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-align: center;
}

.brand-tagline {
  font-size: 11.5px;
  font-weight: 600;
  color: #ffffff !important;
  margin: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.95;
  text-align: center;
}

.doc-identity {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.doc-type-title {
  font-size: 28px;
  font-weight: 800;
  color: #ffffff !important;
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  color: #ffffff !important;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.doc-badge-label {
  opacity: 0.8;
  font-size: 11px;
}

.doc-badge-val {
  font-weight: 700;
}

.header-contact-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 7px;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.contact-line {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  font-size: 11.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.94) !important;
  flex-wrap: wrap;
  width: 100%;
}

.contact-line i {
  color: #ffffff;
  font-size: 11.5px;
  flex-shrink: 0;
}

.contact-channels {
  font-weight: 500;
}

.contact-address {
  color: rgba(255, 255, 255, 0.9) !important;
}

.contact-sep {
  opacity: 0.55;
  margin: 0 4px;
}

/* Backward compatibility fallbacks */
.address-col { display: flex; align-items: flex-start; gap: 10px; font-size: 11.5px; line-height: 1.5; color: rgba(255, 255, 255, 0.92) !important; }
.channels-col { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 11.5px; color: rgba(255, 255, 255, 0.92) !important; }

.channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.channel-row i {
  color: #ffffff;
  font-size: 11px;
}

.channel-sep {
  opacity: 0.5;
}

/* Backward compatibility fallbacks */
.company-info { display: flex; align-items: center; gap: 18px; }
.company-details { display: flex; flex-direction: column; align-items: center; text-align: center; }
.company-details h1 { font-size: 24px; font-weight: 800; color: #ffffff !important; margin-bottom: 3px; font-family: 'Space Grotesk', sans-serif; text-align: center; }
.company-details .company-tagline { font-size: 12px; font-weight: 600; color: #ffffff !important; margin-bottom: 4px; text-align: center; }
.company-details p { font-size: 11.5px; color: rgba(255, 255, 255, 0.9) !important; line-height: 1.4; margin-bottom: 2px; }
.invoice-title { text-align: right; }
.invoice-title h2 { font-size: 28px; font-weight: 800; color: #ffffff !important; margin-bottom: 4px; font-family: 'Space Grotesk', sans-serif; }
.invoice-title .invoice-number { font-size: 14px; color: rgba(255, 255, 255, 0.92) !important; font-weight: 600; }

.invoice-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-bottom: 28px;
}

.customer-info h3,
.invoice-details h3 {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.customer-info p {
  font-size: 13px;
  color: #374151;
  line-height: 1.6;
}

.customer-info .customer-name {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.invoice-details { text-align: right; }

.invoice-details p {
  font-size: 13px;
  color: #374151;
  margin-bottom: 6px;
}

.invoice-details strong { color: #111827; }

/* ── Items Table ── */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 28px;
}

.items-table th {
  background: var(--accent);
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: 'Space Grotesk', sans-serif;
}

.items-table th:last-child { text-align: right; }

.items-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
  color: #374151;
}

.items-table td:last-child { text-align: right; font-weight: 600; }
.items-table tbody tr:hover { background: #f9fafb; }

/* ── Totals Box ── */
.invoice-totals { display: flex; justify-content: flex-end; margin-bottom: 28px; }

.totals-box {
  width: 280px;
  background: #f9fafb;
  padding: 18px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid #e5e7eb;
}

.totals-box .row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

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

.totals-box .row.total {
  border-top: 2px solid var(--accent);
  border-bottom: none;
  padding-top: 12px;
  margin-top: 6px;
}

.totals-box .row span:first-child { font-size: 13px; color: #6b7280; }
.totals-box .row span:last-child { font-size: 13px; font-weight: 600; color: #111827; }
.totals-box .row.total span { font-size: 18px; font-weight: 700; color: var(--accent); font-family: 'Space Grotesk', sans-serif; }

/* ── Payment Information & UPI QR ── */
.payment-info-section {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  margin: 28px 0;
  padding: 22px 24px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  page-break-inside: avoid;
}

.bank-details-box h4,
.upi-qr-box h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Space Grotesk', sans-serif;
}

.bank-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #475569;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 5px;
}

.bank-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.bank-row .label {
  font-weight: 600;
  color: #64748b;
}

.bank-row .val {
  font-weight: 500;
  color: #000000;
}

.bank-row .bold-acc {
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #000000;
  font-family: 'Space Grotesk', monospace;
  font-size: 13px;
}

.bank-row .highlight-upi {
  font-weight: 700;
  color: var(--accent);
  background: rgba(229, 9, 20, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
}

.upi-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-left: 1px solid #e2e8f0;
  padding-left: 18px;
}

.qr-code-wrapper {
  background: #ffffff;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 120px;
  margin-bottom: 8px;
}

.qr-code-wrapper img,
.qr-code-wrapper canvas {
  width: 120px !important;
  height: 120px !important;
  display: block;
}

.qr-scan-note {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 6px;
  font-weight: 500;
}

.upi-apps-icons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.upi-badge {
  font-size: 10px;
  font-weight: 700;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

/* ── Notes ── */
.notes-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.notes-section h4 {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.notes-section p {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.6;
}

/* ── Footer ── */
.invoice-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 2px solid var(--accent);
  text-align: center;
}

.invoice-footer p { font-size: 13px; color: #6b7280; }

.invoice-footer .thank-you {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  font-family: 'Space Grotesk', sans-serif;
}

/* ═══════════════════════════════════════════════════════════════
   LIGHT MODE OVERRIDES — Invoice Styles
   ═══════════════════════════════════════════════════════════════ */

.light-mode .filters-bar,
html.light-mode .filters-bar {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.light-mode .filter-group label,
html.light-mode .filter-group label {
  color: #475569;
}

.light-mode .filter-group select,
.light-mode .filter-group input,
html.light-mode .filter-group select,
html.light-mode .filter-group input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.light-mode .filter-group select:focus,
.light-mode .filter-group input:focus,
html.light-mode .filter-group select:focus,
html.light-mode .filter-group input:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

.light-mode .invoices-card,
html.light-mode .invoices-card {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.light-mode .export-btn,
html.light-mode .export-btn {
  background: #f8fafc;
  border-color: var(--border);
  color: #475569;
}

.light-mode .export-btn:hover,
html.light-mode .export-btn:hover {
  background: rgba(229, 9, 20, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.light-mode .invoices-table th,
html.light-mode .invoices-table th {
  background: #f8fafc;
  color: #475569;
  border-bottom-color: var(--border);
}

.light-mode .invoices-table tbody tr,
html.light-mode .invoices-table tbody tr {
  background: #ffffff;
  border-bottom-color: #f1f5f9;
}

.light-mode .invoices-table tbody tr:nth-child(even),
html.light-mode .invoices-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.light-mode .invoices-table tbody tr:hover,
html.light-mode .invoices-table tbody tr:hover {
  background: rgba(229, 9, 20, 0.04);
  box-shadow: inset 3px 0 0 var(--accent);
}

.light-mode .customer-name,
html.light-mode .customer-name {
  color: #0f172a;
}

.light-mode .amount,
html.light-mode .amount {
  color: #0f172a;
}

.light-mode .action-btn,
html.light-mode .action-btn {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #64748b;
}

.light-mode .table-footer,
html.light-mode .table-footer {
  background: #ffffff;
  border-top-color: var(--border);
}

.light-mode .showing-count,
html.light-mode .showing-count {
  color: #64748b;
}

.light-mode .showing-count strong,
html.light-mode .showing-count strong {
  color: #0f172a;
}

.light-mode .page-btn,
html.light-mode .page-btn {
  background: #ffffff;
  border-color: var(--border);
  color: #475569;
}

.light-mode .invoice-modal,
html.light-mode .invoice-modal {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12);
}

.light-mode .form-group label,
html.light-mode .form-group label {
  color: #475569;
}

.light-mode .form-group input,
.light-mode .form-group select,
.light-mode .form-group textarea,
html.light-mode .form-group input,
html.light-mode .form-group select,
html.light-mode .form-group textarea {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.light-mode .form-group input:focus,
.light-mode .form-group select:focus,
.light-mode .form-group textarea:focus,
html.light-mode .form-group input:focus,
html.light-mode .form-group select:focus,
html.light-mode .form-group textarea:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

.light-mode .form-group input::placeholder,
.light-mode .form-group textarea::placeholder,
html.light-mode .form-group input::placeholder,
html.light-mode .form-group textarea::placeholder {
  color: #94a3b8;
}

.light-mode .items-section,
html.light-mode .items-section {
  background: #f8fafc;
  border-color: var(--border);
}

.light-mode .items-section-header h3,
html.light-mode .items-section-header h3 {
  color: #475569;
}

.light-mode .items-header,
html.light-mode .items-header {
  background: #ffffff;
  border-color: var(--border);
}

.light-mode .items-header span,
html.light-mode .items-header span {
  color: #64748b;
}

.light-mode .item-row input,
.light-mode .item-row select,
.light-mode .item-row textarea,
html.light-mode .item-row input,
html.light-mode .item-row select,
html.light-mode .item-row textarea {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.light-mode .item-row input:focus,
.light-mode .item-row select:focus,
html.light-mode .item-row input:focus,
html.light-mode .item-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.12);
}

.light-mode .item-row .remove-item,
html.light-mode .item-row .remove-item {
  background: #f1f5f9;
  border-color: var(--border);
  color: #64748b;
}

.light-mode .custom-select-trigger,
html.light-mode .custom-select-trigger {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.light-mode .custom-select-menu,
html.light-mode .custom-select-menu {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
}

.light-mode .custom-select-search,
.light-mode .custom-select-footer,
html.light-mode .custom-select-search,
html.light-mode .custom-select-footer {
  background: #f8fafc;
  border-color: var(--border);
}

.light-mode .custom-select-search input,
html.light-mode .custom-select-search input {
  background: #ffffff;
  border-color: var(--border);
  color: #0f172a;
}

.light-mode .custom-select-option,
html.light-mode .custom-select-option {
  color: #334155;
}

.light-mode .custom-select-option:hover,
.light-mode .custom-select-option.selected,
html.light-mode .custom-select-option:hover,
html.light-mode .custom-select-option.selected {
  background: rgba(229, 9, 20, 0.06);
  color: #0f172a;
}

.light-mode .add-item-btn,
.light-mode .custom-select-add-btn,
html.light-mode .add-item-btn,
html.light-mode .custom-select-add-btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

.light-mode .bottom-left-docs .doc-field,
html.light-mode .bottom-left-docs .doc-field {
  background: #f8fafc;
  border-color: var(--border);
}

.light-mode .bottom-left-docs textarea,
html.light-mode .bottom-left-docs textarea {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.light-mode .summary-card,
html.light-mode .summary-card {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.light-mode .summary-card-header,
html.light-mode .summary-card-header {
  color: #475569;
  border-bottom-color: var(--border);
}

.light-mode .summary-label,
html.light-mode .summary-label {
  color: #475569;
}

.light-mode .summary-val,
html.light-mode .summary-val {
  color: #0f172a;
}

.light-mode .grand-label,
html.light-mode .grand-label {
  color: #0f172a;
}

.light-mode .summary-divider,
html.light-mode .summary-divider {
  background: var(--border);
}

.light-mode .discount-pct-group,
html.light-mode .discount-pct-group {
  background: #f8fafc;
  border-color: var(--border);
}

.light-mode .discount-pct-group input,
html.light-mode .discount-pct-group input {
  color: #0f172a;
}

.light-mode .discount-val-input,
html.light-mode .discount-val-input {
  background: #f8fafc;
  border-color: var(--border);
  color: #475569;
}

.light-mode .modal-form-actions,
html.light-mode .modal-form-actions {
  border-top-color: var(--border);
}

.light-mode .modal-form-actions .btn-cancel,
.light-mode .btn-draft,
html.light-mode .modal-form-actions .btn-cancel,
html.light-mode .btn-draft {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #475569;
}

.light-mode .modal-form-actions .btn-cancel:hover,
.light-mode .btn-draft:hover,
html.light-mode .modal-form-actions .btn-cancel:hover,
html.light-mode .btn-draft:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.light-mode .totals-section,
html.light-mode .totals-section {
  background: #f8fafc;
  border-color: var(--border);
}

.light-mode .totals-row,
html.light-mode .totals-row {
  border-bottom-color: var(--border);
}

.light-mode .form-actions,
html.light-mode .form-actions {
  border-top-color: var(--border);
}

.light-mode .btn-secondary,
html.light-mode .btn-secondary {
  background: #ffffff;
  border-color: var(--border);
  color: #475569;
}

.light-mode .invoice-preview-modal,
html.light-mode .invoice-preview-modal {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12);
}

.light-mode .invoice-preview-modal .modal-header,
html.light-mode .invoice-preview-modal .modal-header {
  background: #ffffff;
  border-bottom-color: var(--border);
}

.light-mode .invoice-preview-modal .modal-header h2,
html.light-mode .invoice-preview-modal .modal-header h2 {
  color: #0f172a;
}

.light-mode .preview-btn,
html.light-mode .preview-btn {
  background: #f8fafc !important;
  border-color: var(--border) !important;
  color: #475569 !important;
}

.light-mode .preview-btn:hover,
html.light-mode .preview-btn:hover {
  background: rgba(229, 9, 20, 0.08) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.light-mode .invoice-preview-modal .close-btn,
html.light-mode .invoice-preview-modal .close-btn {
  background: #f8fafc !important;
  border-color: var(--border) !important;
  color: #475569 !important;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Filters Bar */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    gap: 12px;
  }
  .filter-group {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }
  .filter-group label {
    min-width: 72px;
  }
  .filter-group select,
  .filter-group input[type="date"] {
    flex: 1;
    min-width: 120px;
    font-size: 15px; /* prevents iOS zoom */
  }
  .filter-btn {
    width: 100%;
    justify-content: center;
    padding: 11px 20px;
    font-size: 13px;
  }

  /* Modal full-screen on mobile */
  .invoice-modal,
  .invoice-preview-modal {
    max-width: 100%;
    width: 100%;
    max-height: 96vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Preview action buttons stack */
  .invoice-preview-modal .modal-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
  }
  .invoice-preview-modal .preview-actions {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .preview-btn {
    padding: 8px 12px !important;
    font-size: 12px !important;
    flex: 1;
  }

  /* Invoice preview document */
  .invoice-preview {
    padding: 20px 14px;
  }

  /* Item rows stack vertically */
  .items-header {
    display: none;
  }
  .item-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
  }
  .light-mode .item-row {
    background: #f8fafc;
  }
  .item-row input,
  .item-row select,
  .item-row textarea {
    width: 100%;
    box-sizing: border-box;
    font-size: 15px; /* prevents iOS zoom */
    min-height: 42px;
  }
  .item-row .remove-item {
    width: 100%;
    height: 36px;
    border-radius: var(--radius-sm);
  }

  /* Bottom layout stacks */
  .modal-bottom-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Form rows */
  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 15px; /* prevents iOS zoom */
  }

  /* Totals section */
  .totals-section {
    width: 100%;
    margin-left: 0;
  }

  /* Modal actions */
  .modal-form-actions {
    flex-direction: column;
    gap: 10px;
  }
  .modal-form-actions .btn-cancel,
  .action-buttons-right {
    width: 100%;
  }
  .action-buttons-right {
    flex-direction: column;
    gap: 8px;
  }
  .btn-draft,
  .btn-save-primary {
    width: 100%;
    justify-content: center;
  }

  /* Invoice document meta */
  .invoice-header { flex-direction: column; gap: 16px; padding: 20px 18px; }
  .header-top-row { flex-direction: column; align-items: flex-start; gap: 14px; }
  .doc-identity { align-items: flex-start; text-align: left; }
  .header-contact-strip { align-items: center; text-align: center; gap: 8px; }
  .contact-line { justify-content: center; text-align: center; }
  .invoice-title { text-align: left; }
  .invoice-meta { grid-template-columns: 1fr; }
  .invoice-details { text-align: left; }
  .notes-section { grid-template-columns: 1fr; }

  /* Print preview document */
  .payment-info-section {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .filters-bar {
    padding: 12px;
    gap: 10px;
  }
  .invoice-preview {
    padding: 14px 10px;
  }
}



@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .sidebar, .header, .filters-bar, .preview-actions, .modal-header, .close-btn, .pagination, .actions-grid {
    display: none !important;
  }
  .app-container {
    display: block !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
  }
  .modal {
    position: static !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    display: block !important;
  }
  .modal-content {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    background: transparent !important;
  }
  .modal-body {
    padding: 0 !important;
  }
  .invoice-preview {
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    background: #ffffff !important;
    color: #000000 !important;
  }
  .invoice-print {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .payment-info-section {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .invoice-header {
    background: #dc2626 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    padding: 20px 24px !important;
    border-radius: 8px !important;
    margin-bottom: 24px !important;
  }
  .company-details h1, .invoice-title h2, .company-details .company-tagline, .invoice-title .invoice-number {
    color: #ffffff !important;
  }
  .items-table th {
    background: #dc2626 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .totals-box {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
