/* ═══════════════════════════════════════════════════════════════════════
   style.css — InvoiceCraft Application Styles
   Dark professional UI theme + A4 invoice document styles
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Fonts ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@600&display=swap');

/* ── Reset & Base ────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* App UI colors */
  --bg:            #0f1117;
  --bg-surface:    #1a1d27;
  --bg-elevated:   #21253a;
  --bg-input:      #13161f;
  --border:        #2a2f45;
  --border-focus:  #4f6ef7;
  --text-primary:  #e8eaf6;
  --text-secondary:#8b8fa8;
  --text-muted:    #555a70;
  --accent:        #4f6ef7;
  --accent-light:  #7b96ff;
  --accent-hover:  #3a56d4;
  --danger:        #e05252;
  --danger-hover:  #c43c3c;
  --success:       #52c77a;
  --warning:       #e8a838;

  /* Invoice document colors */
  --inv-bg:        #ffffff;
  --inv-text:      #1a1a2e;
  --inv-text-sec:  #555577;
  --inv-accent:    #1a2c8a;
  --inv-accent2:   #2d3f9e;
  --inv-border:    #d5d8e8;
  --inv-bg-header: #1a2c8a;
  --inv-bg-total:  #f4f5fb;
  --inv-row-alt:   #f9f9fd;

  /* Spacing */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   16px;

  /* Typography */
  --font-ui:    'Inter', system-ui, sans-serif;
  --font-inv:   'Inter', Georgia, serif;
}

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1;
  min-height: 0;
  gap: 0;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}

.app-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.app-brand-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.5px;
  line-height: 1;
}

.app-brand-name span {
  color: var(--text-primary);
}

.app-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.app-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(79,110,247,0.35); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #2a2f4a; border-color: #3a4060; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(224,82,82,0.3);
}
.btn-danger-outline:hover { background: rgba(224,82,82,0.1); }

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Grouped Export / Import buttons */
.btn-group {
  display: flex;
  align-items: center;
}

.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}

.btn-group .btn:first-child {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}

.btn-group .btn:last-child {
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  border-right-width: 1px;
}

/* User profile badge and auth buttons */
.user-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
}

.user-name {
  color: #f1f5f9;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout-bar {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-weight: 600;
}

.btn-logout-bar svg {
  color: #f87171;
}

.btn-logout-bar:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.2);
}

.btn-login-bar {
  background: var(--accent);
  color: #ffffff;
  border: 1px solid transparent;
  font-weight: 600;
}

.btn-login-bar:hover {
  background: var(--accent-hover);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
}

/* ── Sample Data Banner ──────────────────────────────────────────────── */
#sample-banner {
  background: linear-gradient(90deg, rgba(79,110,247,0.12), rgba(79,110,247,0.05));
  border-bottom: 1px solid rgba(79,110,247,0.2);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--accent-light);
  gap: 12px;
}

#sample-banner span { flex: 1; }

#sample-banner strong { color: #fff; }

#dismiss-sample {
  background: transparent;
  border: 1px solid rgba(79,110,247,0.35);
  color: var(--accent-light);
  padding: 5px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: background 0.18s;
  white-space: nowrap;
}
#dismiss-sample:hover { background: rgba(79,110,247,0.15); }

/* ── Editor Panel ────────────────────────────────────────────────────── */
.editor-panel {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.editor-inner {
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Editor Sections ─────────────────────────────────────────────────── */
.editor-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 12px;
  background: var(--bg-elevated);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-elevated);
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.section-header:hover {
  background: #252940;
}

.editor-section:not(.collapsed) .section-header {
  border-bottom-color: var(--border);
}

.section-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(79,110,247,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-icon svg {
  width: 14px;
  height: 14px;
  color: var(--accent-light);
  stroke: currentColor;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: 0.2px;
}

.section-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s;
  stroke: currentColor;
}

.editor-section.collapsed .section-chevron {
  transform: rotate(-90deg);
}

.section-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-section.collapsed .section-body {
  display: none;
}

/* ── Form Fields ─────────────────────────────────────────────────────── */
.form-row {
  display: grid;
  gap: 10px;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

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

.form-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13.5px;
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
  appearance: none;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}

.field-input::placeholder,
.field-textarea::placeholder {
  color: var(--text-muted);
}

.field-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

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

.field-input[type="number"] {
  -moz-appearance: textfield;
}
.field-input[type="number"]::-webkit-outer-spin-button,
.field-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* ── Calendar / date picker icon — make visible in dark mode ── */
.field-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) brightness(1.4);
  cursor: pointer;
  opacity: 0.75;
  padding: 2px;
  border-radius: 3px;
  transition: opacity 0.15s;
}
.field-input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  filter: invert(0.5) brightness(2) sepia(1) hue-rotate(190deg);
}

/* ── Input with inline action button (e.g. invoice number + generate) ── */
.input-with-btn {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.input-with-btn .field-input {
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  flex: 1;
}

.input-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.input-action-btn:hover {
  background: #2a2f4a;
  color: var(--accent-light);
}

.input-action-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

/* ── Logo Upload ─────────────────────────────────────────────────────── */
.logo-upload-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.logo-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--bg-input);
  border: 1.5px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
  font-family: var(--font-ui);
}

.logo-upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.logo-upload-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

#logo-input { display: none; }

.logo-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

#logo-preview {
  max-width: 120px;
  max-height: 60px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px;
  display: none;
}

#logo-clear {
  display: none;
  background: transparent;
  border: 1px solid rgba(224,82,82,0.35);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-ui);
  align-items: center;
  gap: 5px;
  transition: background 0.18s;
}

#logo-clear:hover { background: rgba(224,82,82,0.1); }

/* ── Line Items ─────────────────────────────────────────────────────── */
#items-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px; /* room for scrollbar */
}

.item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color 0.18s;
  min-width: 560px; /* ensures fields never get clipped — container scrolls */
}

.item-row:hover {
  border-color: #3a4060;
}

/* Thin scrollbar for items container */
#items-container::-webkit-scrollbar {
  height: 8px;
  display: block;
}
#items-container::-webkit-scrollbar-track {
  background: #0f1117;
  border-radius: 4px;
  border: 1px solid var(--border);
}
#items-container::-webkit-scrollbar-thumb {
  background: #3a4060;
  border-radius: 4px;
  border: 1px solid #4a5070;
}
#items-container::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.item-row-number {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding-top: 22px;
  min-width: 18px;
  text-align: center;
}

.item-row-fields {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 80px 100px 90px 32px;
  gap: 8px;
  align-items: end;
}

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

.item-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.item-amount-display {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  font-size: 13.5px;
  color: var(--accent-light);
  font-weight: 500;
  text-align: right;
}

/* Note input inside item row */
.item-note-input {
  margin-top: 5px;
  font-size: 11.5px !important;
  padding: 5px 10px !important;
  color: var(--text-secondary) !important;
  background: rgba(255,255,255,0.03) !important;
}

.item-note-input::placeholder {
  font-style: italic;
  color: var(--text-muted) !important;
}

/* Invoice preview — item name & note */
.inv-item-name {
  font-weight: 500;
  color: var(--inv-text);
  line-height: 1.4;
}

.inv-item-note {
  font-size: 11px;
  color: var(--inv-text-sec);
  font-style: italic;
  margin-top: 3px;
  line-height: 1.45;
}

.btn-remove-item {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid rgba(224,82,82,0.25);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
  margin-top: 18px;
}

.btn-remove-item:hover {
  background: rgba(224,82,82,0.12);
  border-color: var(--danger);
}

.btn-remove-item svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
}

.items-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

#add-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1.5px dashed rgba(79,110,247,0.4);
  color: var(--accent-light);
  padding: 8px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  transition: background 0.15s, border-color 0.15s;
}

#add-item-btn:hover {
  background: rgba(79,110,247,0.07);
  border-color: var(--accent);
}

#add-item-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

/* ── Editor Totals Summary ───────────────────────────────────────────── */
#editor-totals {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.etotal-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}

.etotal-grand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Discount Row ────────────────────────────────────────────────────── */
.discount-row {
  display: flex;
  gap: 10px;
}

.discount-row .form-group:first-child {
  flex: 1;
}

.discount-row .form-group:last-child {
  flex: 1;
}

#discount-value-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ── Preview Panel ───────────────────────────────────────────────────── */
.preview-panel {
  background: #dde0e8;
  overflow-y: auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 16px;
  font-weight: 600;
}

/* ── Invoice Document ─────────────────────────────────────────────────── */
#invoice-preview {
  width: 100%;
  max-width: 794px; /* A4 width at 96dpi */
}

.inv-doc {
  background: var(--inv-bg);
  color: var(--inv-text);
  font-family: var(--font-inv);
  padding: 48px 52px;
  min-height: 1100px;
  box-shadow: 0 4px 40px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.08);
  border-radius: 2px;
  position: relative;
}

/* ── Invoice Header ─────────────────────────────────────────────────── */
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
}

.inv-from {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.inv-logo img {
  max-width: 160px;
  max-height: 70px;
  object-fit: contain;
  display: block;
}

.inv-from-details {
  line-height: 1.55;
}

.inv-business-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--inv-accent);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.inv-addr-line {
  font-size: 12.5px;
  color: var(--inv-text-sec);
}

.inv-contact-line {
  font-size: 12.5px;
  color: var(--inv-text-sec);
}

.inv-title-block {
  text-align: right;
  flex-shrink: 0;
}

.inv-title {
  font-size: 36px;
  font-weight: 700;
  color: var(--inv-accent);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}

.inv-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--inv-text-sec);
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

.inv-meta-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.inv-meta-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 12.5px;
}

.inv-meta-label {
  color: var(--inv-text-sec);
  min-width: 90px;
  text-align: right;
}

.inv-meta-value {
  font-weight: 500;
  color: var(--inv-text);
  min-width: 120px;
  text-align: right;
}

/* ── Invoice Divider ─────────────────────────────────────────────────── */
.inv-divider {
  border: none;
  border-top: 2px solid var(--inv-accent);
  margin: 0 0 24px;
  opacity: 0.15;
}

/* ── Bill To ─────────────────────────────────────────────────────────── */
.inv-bill-section {
  margin-bottom: 28px;
}

.inv-bill-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--inv-accent);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--inv-border);
}

.inv-customer-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--inv-text);
  margin-bottom: 2px;
}

/* ── Items Table ─────────────────────────────────────────────────────── */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  font-size: 13px;
}

.inv-table thead tr {
  background: var(--inv-accent);
}

.inv-table thead th {
  color: #fff;
  font-weight: 600;
  padding: 10px 12px;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.inv-th-desc { text-align: left; }
.inv-th-num { text-align: right; }

.inv-table tbody tr {
  border-bottom: 1px solid var(--inv-border);
}

.inv-table tbody tr:nth-child(even) {
  background: var(--inv-row-alt);
}

.inv-table tbody tr:last-child {
  border-bottom: 2px solid var(--inv-border);
}

.inv-td-desc {
  padding: 10px 12px;
  color: var(--inv-text);
  word-break: break-word;
}

.inv-td-num {
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
  color: var(--inv-text-sec);
}

.inv-td-amount {
  font-weight: 600;
  color: var(--inv-text);
}

.inv-empty-row {
  padding: 20px 12px;
  text-align: center;
  color: #aaa;
  font-style: italic;
}

.inv-placeholder {
  color: #ccc;
  font-style: italic;
}

/* ── Totals Section ──────────────────────────────────────────────────── */
.inv-totals-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  margin-bottom: 28px;
}

.inv-totals-table {
  min-width: 280px;
  background: var(--inv-bg-total);
  border: 1px solid var(--inv-border);
  border-radius: 4px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inv-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  font-size: 13px;
}

.inv-total-label {
  color: var(--inv-text-sec);
  font-weight: 500;
}

.inv-total-value {
  font-weight: 600;
  color: var(--inv-text);
  text-align: right;
  white-space: nowrap;
}

.inv-discount-row .inv-total-value {
  color: #c0392b;
}

.inv-total-divider {
  border-top: 1.5px solid var(--inv-border);
  margin: 4px 0;
}

.inv-grand-total-row {
  margin-top: 2px;
}

.inv-grand-total-row .inv-total-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--inv-accent);
  letter-spacing: 0.5px;
}

.inv-grand-total-row .inv-total-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--inv-accent);
}

/* ── Footer (Notes / Terms) ──────────────────────────────────────────── */
.inv-footer-section {
  border-top: 1px solid var(--inv-border);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inv-footer-block {}

.inv-footer-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--inv-accent);
  text-transform: uppercase;
  margin-bottom: 5px;
}

.inv-footer-text {
  font-size: 12.5px;
  color: var(--inv-text-sec);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 20px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  opacity: 0;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Validation Modal ────────────────────────────────────────────────── */
#validation-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

#validation-modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  min-width: 340px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.modal-errors {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.modal-errors li {
  padding: 10px 14px;
  background: rgba(224,82,82,0.08);
  border: 1px solid rgba(224,82,82,0.2);
  border-radius: var(--r-sm);
  color: #f08080;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.modal-errors li::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(224,82,82,0.25);
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  flex-shrink: 0;
  margin-top: 1px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

/* ── Payment Status Stamp ────────────────────────────────────────────── */
.inv-stamp {
  position: absolute;
  top: 52px;
  right: 48px;
  padding: 10px 22px;
  border-width: 4px;
  border-style: double;
  border-radius: 4px;
  font-family: 'Inter', monospace, sans-serif;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 6px;
  text-transform: uppercase;
  transform: rotate(-22deg);
  transform-origin: center;
  opacity: 0.82;
  pointer-events: none;
  user-select: none;
  z-index: 10;
  white-space: nowrap;
  line-height: 1;
}

.stamp-paid {
  color: #1a7a3c;
  border-color: #1a7a3c;
  background: rgba(26, 122, 60, 0.04);
  text-shadow: 0 0 1px rgba(26, 122, 60, 0.2);
}

.stamp-unpaid {
  color: #b91c1c;
  border-color: #b91c1c;
  background: rgba(185, 28, 28, 0.04);
  text-shadow: 0 0 1px rgba(185, 28, 28, 0.2);
}

.stamp-partial {
  color: #b45309;
  border-color: #b45309;
  background: rgba(180, 83, 9, 0.04);
  text-shadow: 0 0 1px rgba(180, 83, 9, 0.2);
}

/* ── Status select dot colours ───────────────────────────────────────── */
#inv-status option[value="unpaid"] { color: #e05252; }
#inv-status option[value="paid"]   { color: #52c77a; }
#inv-status option[value="partial"]{ color: #e8a838; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .preview-panel {
    padding: 24px 12px;
  }

  .inv-doc {
    padding: 32px 24px;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 14px;
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .app-brand-name { font-size: 17px; }

  .app-header-actions .btn span { display: none; }
  .app-header-actions .btn-logout-bar span,
  .app-header-actions .btn-login-bar span { display: inline; }

  .editor-inner {
    padding: 14px 14px 40px;
  }

  .item-row-fields {
    grid-template-columns: 1fr 70px 90px 80px 32px;
  }

  .inv-header {
    flex-direction: column;
    gap: 16px;
  }

  .inv-title-block {
    text-align: left;
  }

  .inv-title { font-size: 26px; }

  .inv-meta-table {
    text-align: left;
  }

  .inv-meta-row {
    justify-content: flex-start;
  }

  .inv-totals-section {
    justify-content: stretch;
  }

  .inv-totals-table {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .item-row-fields {
    grid-template-columns: 1fr;
  }
  .item-row-number { display: none; }
  .btn-remove-item { margin-top: 0; width: 100%; }
}
