/* ── Variables ──────────────────────────────────────────────── */
:root {
  --brand:       #1e40af;
  --brand-light: #dbeafe;
  --brand-dark:  #1e3a8a;
  --accent:      #0ea5e9;
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --radius:      10px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --sidebar-w:   240px;
  --topbar-h:    56px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       background: var(--bg); color: var(--text); line-height: 1.5; }
button { cursor: pointer; font: inherit; border: none; background: none; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--text);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sb-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; }
.sb-company { font-weight: 700; font-size: .95rem; line-height: 1.2; }
.sb-tagline { font-size: .72rem; opacity: .5; margin-top: 2px; }

.sidebar-nav { display: flex; flex-direction: column; padding: 12px 8px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: .88rem;
  color: rgba(255,255,255,.7);
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.1);
  color: white;
}
.nav-link.active { background: var(--brand); color: white; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-link-bottom { margin-top: auto; }

/* Top bar (mobile only) */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.menu-btn { font-size: 1.3rem; color: var(--text); padding: 6px; }
.tb-title { flex: 1; font-weight: 600; font-size: .95rem; }

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 45;
}

/* Main content */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 28px 32px;
}
.view { max-width: 960px; margin: 0 auto; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { color: var(--text-muted); padding: 8px 10px; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body { padding: 20px 24px; }
.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-size: .9rem;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-light);
}
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Stats Cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }
.stat-sub { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.stat-card.stat-brand { border-color: var(--brand); }
.stat-card.stat-brand .stat-value { color: var(--brand); }
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-danger .stat-value { color: var(--danger); }

/* ── Badge / Status ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-draft    { background: #f1f5f9; color: #475569; }
.badge-sent     { background: #dbeafe; color: #1e40af; }
.badge-paid     { background: #dcfce7; color: #15803d; }
.badge-overdue  { background: #fee2e2; color: #dc2626; }
.badge-cancelled{ background: #fef3c7; color: #92400e; }

/* ── Invoice Table / List ───────────────────────────────────── */
.invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.invoice-table th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.invoice-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.invoice-table tr:last-child td { border-bottom: none; }
.invoice-table tbody tr:hover { background: var(--bg); }
.invoice-table .col-num  { font-weight: 600; color: var(--brand); }
.invoice-table .col-amount { font-weight: 600; text-align: right; }
.invoice-table .col-actions { text-align: right; white-space: nowrap; }
.invoice-table .col-date { color: var(--text-muted); font-size: .82rem; }

.table-actions-group { display: flex; gap: 4px; justify-content: flex-end; }

/* ── Filters / Search ───────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar .form-control { width: auto; flex: 1; min-width: 180px; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
}
.filter-tab:hover { background: var(--bg); }
.filter-tab.active { background: var(--brand); color: white; border-color: var(--brand); }

/* ── Line Items Table ───────────────────────────────────────── */
.line-items-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.line-items-table th {
  background: var(--bg);
  padding: 9px 12px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.line-items-table td { padding: 8px 4px; border-bottom: 1px solid var(--border); }
.line-items-table td:first-child { padding-left: 0; }
.line-items-table td:last-child { padding-right: 0; }
.line-items-table .line-desc { width: 40%; }
.line-items-table .line-qty  { width: 12%; }
.line-items-table .line-unit { width: 18%; }
.line-items-table .line-tax  { width: 12%; }
.line-items-table .line-total{ width: 16%; text-align: right; }
.line-items-table .line-del  { width: 4%; text-align: center; }
.line-items-table .form-control { padding: 7px 10px; }

.line-total-display {
  text-align: right;
  font-weight: 500;
  padding: 7px 10px;
  font-size: .88rem;
}

.line-items-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 16px;
}

/* ── Totals Box ─────────────────────────────────────────────── */
.totals-box {
  min-width: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  font-size: .88rem;
  border-bottom: 1px solid var(--border);
}
.totals-row:last-child { border-bottom: none; }
.totals-row.totals-grand {
  background: var(--brand);
  color: white;
  font-weight: 700;
  font-size: 1rem;
}
.totals-label { color: var(--text-muted); }
.totals-row.totals-grand .totals-label { color: rgba(255,255,255,.8); }
.totals-value { font-weight: 500; }

/* ── Dividers / Sections ────────────────────────────────────── */
.section { margin-bottom: 28px; }
.section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Logo Upload ────────────────────────────────────────────── */
.logo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.logo-upload-area:hover, .logo-upload-area.drag-over {
  border-color: var(--brand);
  background: var(--brand-light);
}
.logo-upload-area input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.logo-preview {
  max-height: 80px;
  max-width: 200px;
  object-fit: contain;
  margin-bottom: 8px;
}
.logo-upload-hint { font-size: .8rem; color: var(--text-muted); }

/* ── Color Picker ───────────────────────────────────────────── */
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.color-swatch {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; transition: transform .15s, border-color .15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text); }
input[type="color"] { width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 50%; cursor: pointer; }

/* ── Invoice Preview (View mode) ────────────────────────────── */
.invoice-preview {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.inv-header {
  background: var(--brand);
  color: white;
  padding: 32px 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}
.inv-logo { max-height: 70px; max-width: 180px; object-fit: contain; border-radius: 4px; }
.inv-company-name { font-size: 1.3rem; font-weight: 700; }
.inv-company-details { font-size: .8rem; opacity: .85; margin-top: 4px; line-height: 1.6; white-space: pre-line; }
.inv-title-block { text-align: right; }
.inv-title-word { font-size: 2rem; font-weight: 800; opacity: .15; letter-spacing: .1em; }
.inv-number { font-size: 1.1rem; font-weight: 700; margin-top: 4px; }
.inv-dates { font-size: .8rem; opacity: .85; margin-top: 8px; line-height: 1.8; }

.inv-body { padding: 32px 40px; }

.inv-addresses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 28px;
}
.inv-address-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.inv-address-name { font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.inv-address-detail { font-size: .85rem; color: var(--text-muted); white-space: pre-line; line-height: 1.6; }

.inv-items-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.inv-items-table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.inv-items-table th:last-child { text-align: right; }
.inv-items-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
  vertical-align: top;
}
.inv-items-table td:last-child { text-align: right; font-weight: 500; }
.inv-items-table .item-desc { font-weight: 500; }
.inv-items-table .item-meta { color: var(--text-muted); font-size: .8rem; margin-top: 2px; }
.inv-items-table tbody tr:last-child td { border-bottom: 2px solid var(--border); }

.inv-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}
.inv-notes { flex: 1; min-width: 200px; }
.inv-notes-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.inv-notes-text { font-size: .84rem; color: var(--text-muted); white-space: pre-line; line-height: 1.6; }

.inv-totals { min-width: 220px; }
.inv-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: .88rem;
  border-bottom: 1px solid var(--border);
}
.inv-totals-row:last-child { border-bottom: none; }
.inv-totals-label { color: var(--text-muted); }
.inv-totals-grand {
  background: var(--brand);
  color: white;
  border-radius: 7px;
  padding: 10px 14px;
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
}
.inv-totals-grand .inv-totals-label { color: rgba(255,255,255,.8); }

.inv-bank {
  background: var(--bg);
  border-radius: 7px;
  padding: 14px 40px;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.inv-bank strong { color: var(--text); }
.inv-bank-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── Empty States ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: .4; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-text { font-size: .9rem; margin-bottom: 20px; }

/* ── Toast ──────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  animation: slideUp .25s ease;
}
.toast.toast-success { background: var(--success); }
.toast.toast-error   { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-8px); } }

/* ── Misc ───────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.font-mono { font-family: 'Courier New', monospace; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100%;
    transition: left .25s ease;
    z-index: 60;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay { display: block !important; }
  .sidebar-overlay.hidden { display: none !important; }
  .topbar { display: flex; }
  .main-content { padding: 20px 16px; padding-top: calc(var(--topbar-h) + 16px); }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .inv-header { flex-direction: column; }
  .inv-title-block { text-align: left; }
  .inv-addresses { grid-template-columns: 1fr; gap: 16px; }
  .inv-footer { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .invoice-table { font-size: .8rem; }
  .invoice-table th:nth-child(3),
  .invoice-table td:nth-child(3) { display: none; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Print Styles ───────────────────────────────────────────── */
.print-frame { display: none; }

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #app { display: none; }
  #toasts { display: none; }
  .print-frame {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: white;
  }
  .print-frame .invoice-preview,
  .print-frame .invoice-v2 {
    box-shadow: none;
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 32px 44px;
  }
  .page-header, .filter-bar, .sidebar, .topbar { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   Invoice V2 — Dance Studio Style Layout
   ═══════════════════════════════════════════════════════════════ */

.invoice-v2 {
  background: white;
  padding: 44px 52px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-family: Arial, Helvetica, sans-serif;
  max-width: 760px;
  margin: 0 auto 20px;
  font-size: 13px;
  color: #000;
}

/* Header: Company left, Logo right */
.inv2-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 20px;
}
.inv2-company-block { flex: 1; }
.inv2-company-name  { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.inv2-company-line  { font-size: 12.5px; line-height: 1.6; }
.inv2-company-email { font-size: 12px; color: #0000cc; }
.inv2-logo-block    { max-width: 220px; flex-shrink: 0; text-align: right; }
.inv2-logo-img      { max-width: 210px; max-height: 90px; object-fit: contain; }
.inv2-logo-placeholder { font-size: 1.3rem; font-weight: 800; }

/* Date row */
.inv2-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.inv2-date    { font-weight: 700; font-size: 13.5px; }
.inv2-meta-right { text-align: right; font-size: 12px; color: #444; line-height: 1.7; }
.inv2-inv-num { font-size: 12px; }

/* Client / Student */
.inv2-client-block  { margin-bottom: 18px; }
.inv2-client-label  { font-weight: 700; text-decoration: underline; font-size: 13.5px; display: inline; }
.inv2-client-name   { font-weight: 700; font-size: 14px; margin-top: 3px; }
.inv2-client-extra  { font-size: 12px; color: #555; margin-top: 2px; }

/* Line items table */
.inv2-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
}
.inv2-th {
  font-weight: 700;
  text-decoration: underline;
  padding: 7px 8px 5px;
  border-bottom: 1px solid #aaa;
  font-size: 13px;
}
.inv2-th-desc { text-align: left; }
.inv2-th-right { text-align: right; }
.inv2-table tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  font-size: 12.5px;
}
.inv2-td-desc  { text-align: left; width: 50%; }
.inv2-td-qty   { text-align: right; }
.inv2-td-unit  { text-align: right; }
.inv2-td-tax   { text-align: right; }
.inv2-td-total { text-align: right; font-weight: 500; }

/* Table footer (totals) */
.inv2-tfoot-left {
  vertical-align: bottom;
  padding: 10px 8px 6px;
}
.inv2-tfoot-total-cell {
  text-align: right;
  padding: 10px 8px 6px;
  border-top: 2px solid #888;
  vertical-align: bottom;
}
.inv2-subtotal-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
}
.inv2-grand-total-line {
  font-size: 13.5px;
  font-weight: 700;
}
.inv2-inline-notes { font-size: 11.5px; color: #666; }

/* Bottom: Banking left, Payment right */
.inv2-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  border: 1px solid #bbb;
  padding: 14px 16px;
  margin-top: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.inv2-banking-block { flex: 1; min-width: 200px; }
.inv2-banking-title {
  font-weight: 700;
  text-decoration: underline;
  margin-bottom: 7px;
  font-size: 13px;
}
.inv2-banking-block div { font-size: 12.5px; line-height: 1.75; }
.inv2-bank-ref { font-style: italic; margin-top: 7px; font-size: 12px; }

.inv2-payment-block {
  text-align: right;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
}
.inv2-paid-note {
  font-style: italic;
  font-size: 12.5px;
  color: #555;
  margin-bottom: 8px;
}
.inv2-total-due-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.inv2-total-due-label {
  font-weight: 700;
  text-decoration: underline;
  font-size: 13.5px;
  white-space: nowrap;
}
.inv2-total-due-amount {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

/* Footer message */
.inv2-footer-text {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 0 4px;
}

/* Responsive */
@media (max-width: 600px) {
  .invoice-v2 { padding: 24px 20px; }
  .inv2-head   { flex-direction: column-reverse; }
  .inv2-logo-block { text-align: left; }
  .inv2-bottom { flex-direction: column; }
  .inv2-payment-block { text-align: left; align-items: flex-start; }
  .inv2-total-due-row { justify-content: flex-start; }
  .inv2-meta-row { flex-direction: column; gap: 4px; }
  .inv2-meta-right { text-align: left; }
}
