/* ================================
   Base layout / global
   ================================ */

:root {
  --bg-body: #f5f5f7;
  --bg-card: #ffffff;
  --bg-accent: #1976d2;
  --bg-accent-soft: rgba(25, 118, 210, 0.08);
  --border-subtle: #dddddd;
  --border-strong: #bbbbbb;
  --text-main: #202124;
  --text-muted: #666666;
  --text-invert: #ffffff;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.06);
  --font-base: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body {
  margin: 0;
  padding: 1.5rem;
  font-family: var(--font-base);
  background: var(--bg-body);
  color: var(--text-main);
}

.invoice-app {
  max-width: 1100px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.4rem 1.8rem 2rem;
  box-sizing: border-box;
}

/* ================================
   Toolbar
   ================================ */

.app-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;   /* keeps title + labels aligned nicely */
  margin-bottom: 1rem;
  flex-wrap: nowrap;         /* ⬅ no wrapping on desktop */
}

.app-toolbar h1 {
  margin: 0;
  font-size: 1.6rem;
}

/* App title + tagline block */
.app-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Tagline under main title */
.app-tagline {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Languages line under tagline */
.app-languages {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-sub-actions {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.app-sub-actions .btn {
  font-size: 0.8rem;
  padding: 0.25rem 0.9rem;
}

.app-sub-actions a {
  text-decoration: none;
  font-weight: 500;
}

.app-sub-actions a:hover {
  text-decoration: underline;
}

.sub-actions-separator {
  margin: 0 0.15rem;
}

.toolbar-right {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: nowrap;         /* ⬅ keep language/theme/buttons in one row */
}

.toolbar-left {
  flex: 1 1 auto;
  min-width: 220px;
}


.toolbar-group {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
}

.toolbar-group label {
  margin-bottom: 0.1rem;
}

/* ================================
   Buttons
   ================================ */

.btn {
  border-radius: 999px;
  padding: 0.33rem 0.85rem;
  border: 1px solid var(--bg-accent);
  background: var(--bg-accent);
  color: var(--text-invert);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(0.95);
}

.btn:active {
  filter: brightness(0.9);
}

.btn-ghost {
  background: transparent;
  color: var(--bg-accent);
}

.btn-outline {
  border-style: dashed;
  background: transparent;
  color: var(--bg-accent);
}

.btn-primary {
  font-weight: 600;
}

/* ================================
   Layout helpers
   ================================ */

.editor-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.col {
  box-sizing: border-box;
}

.col-50 {
  flex: 1 1 320px;
}

.col-60 {
  flex: 1 1 60%;
}

.col-40 {
  flex: 1 1 35%;
}

/* Make columns into flex containers, allowing children to stretch */
.row > .col {
  display: flex;
  flex-direction: column;
}

/* Target the payment details card specifically to make it stretch */
#payment-details-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

/* Target the container of the notes textarea */
#payment-details-section .field-group {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

/* Make the notes textarea itself stretch to fill its container */
#payment-details-section #notes {
  flex-grow: 1;
}

/* ================================
   Cards / sections
   ================================ */

.card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 0.7rem 0.9rem;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  margin-bottom: 0.6rem;
}

.card h2 {
  margin: 0 0 0.6rem;
  font-size: 1.08rem;
  font-weight: 600;
  color: #222;
  letter-spacing: 0.01em;
}

/* Extra spacing when cards follow each other in the same column */
.card + .card {
  margin-top: 0.3rem;
}

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

/* ================================
   Form fields
   ================================ */

.field-group {
  margin-bottom: 0.35rem;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.field-row .field-group {
  flex: 1 1 130px;
}

/* Slightly tighter spacing in invoice meta cards (editor) */
#invoice-details-section .field-group,
#payment-details-section .field-group {
  margin-bottom: 0.25rem;
}

label {
  font-size: 0.82rem;
  display: block;
  margin-bottom: 0.18rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid #dddddd;
  font: inherit;
  box-sizing: border-box;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

textarea {
  min-height: 60px;
  resize: vertical;
}

.inline-with-button {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.inline-with-button input {
  flex: 1;
}

/* ================================
   Logos / signature / stamp
   ================================ */

.logo-block {
  margin-bottom: 0.4rem;
}

.logo-preview {
  max-height: 60px;
  display: block;
  margin-bottom: 0.3rem;
}

.signature-stamp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.signature-block,
.stamp-block {
  flex: 1 1 150px;
}

.signature-preview,
.stamp-preview {
  max-width: 160px;
  max-height: 80px;
  display: block;
  margin-top: 0.3rem;
}

/* ================================
   Items table
   ================================ */

#items-section {
  margin-top: 0.3rem;
}

#items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.4rem;
  font-size: 0.88rem;
}

#items-table th,
#items-table td {
  padding: 0.32rem 0.4rem;
  border-bottom: 1px solid #e0e0e0;
}

#items-table th {
  text-align: left;
  font-size: 0.78rem;
  color: var(--text-muted);
}

#items-table tbody tr:hover {
  background-color: #f9fafb;
}

#items-table td.text-right,
.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.item-desc-input {
  width: 100%;
}

.item-qty-input,
.item-unit-price-input,
.item-period-from,
.item-period-to {
  width: 100%;
  box-sizing: border-box;
}

.item-remove-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: #b00020;
}

/* ================================
   Totals
   ================================ */

.totals-card {
  margin-top: 0.3rem;
}

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

.totals-table td {
  padding: 0.16rem 0;
}

.label-cell {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.value-cell {
  font-variant-numeric: tabular-nums;
}

.grand-total-row {
  border-top: 1px solid var(--border-strong);
}

.grand-total-label {
  font-weight: 600;
}

.grand-total-value {
  font-weight: 700;
  font-size: 1.05rem;
}

/* Tax rate inline input */
.tax-rate-input {
  width: 3.5rem;
  display: inline-block;
  text-align: right;
  margin-left: 0.2rem;
}

/* ================================
   QR block
   ================================ */

.qr-wrapper {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.4rem;
}

#qr-code canvas {
  display: block;
}

/* ================================
   Templates
   ================================ */

.templates-card {
  margin-top: 0.5rem;
}

.templates-card .inline-with-button button {
  font-size: 0.8rem;
}

/* ================================
   Premium teaser (PRO placeholder)
   ================================ */

.premium-teaser {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border: 1px dashed var(--border-subtle);
  background: rgba(25, 118, 210, 0.05);
  border-radius: 8px;
}

/* This highly specific selector overrides the default .card + .card margin */
#buyer-section + .premium-teaser {
  margin-top: 5.5rem; /* Adjust this value for perfect vertical centering */
}

.premium-teaser-list {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.premium-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-accent);
  color: var(--text-invert);
}

.premium-teaser-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.premium-teaser-title {
  font-size: 0.82rem;
  font-weight: 600;
}

.premium-teaser-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ================================
   Helpers / messages
   ================================ */

.hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
}

.checkbox-inline input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

/* ================================
   Visibility control classes
   ================================ */

.screen-only {
  display: block;
}

.print-only {
  display: none;
}

.hide-on-print {
  /* JS will add this to hide specific blocks in print */
}

.us-only {
  display: none; /* Will be shown in US mode by JS */
}

/* ================================
   Dark theme
   ================================ */

body.dark-theme {
  background: #121212;
  color: #e5e5e5;
}

body.dark-theme .invoice-app {
  background: #1e1e1e;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
}

body.dark-theme .card {
  background: #262626;
  border-color: #333333;
}

body.dark-theme input[type="text"],
body.dark-theme input[type="number"],
body.dark-theme input[type="date"],
body.dark-theme textarea,
body.dark-theme select {
  background: #1b1b1b;
  border-color: #444444;
  color: #f2f2f2;
}

body.dark-theme #items-table th,
body.dark-theme #items-table td {
  border-bottom-color: #333333;
}

body.dark-theme .hint-text {
  color: #999999;
}

body.dark-theme .btn {
  border-color: #90caf9;
  background: #1976d2;
}

body.dark-theme .btn-ghost {
  background: transparent;
  color: #90caf9;
}

body.dark-theme .premium-teaser {
  background: rgba(25, 118, 210, 0.18);
  border-color: #315f99;
}

body.dark-theme .premium-teaser-subtitle,
body.dark-theme .premium-teaser-list {
  color: #c2c2c2;
}

/* Fix outline buttons (like "Add item") in dark theme */
body.dark-theme .btn-outline,
.dark-theme .btn-outline {
  background: transparent;   /* keep it outline-only */
  color: #90caf9;            /* visible text on dark background */
  border-color: #90caf9;     /* match text color */
}

/* ================================
   Documentation modal
   ================================ */

body.has-doc-modal-open {
  overflow: hidden;
}

#doc-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 2000;
  font-size: 0.85rem;
}

#doc-modal.is-visible {
  display: block;
}

#doc-modal .doc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

/* Dialog container */
#doc-modal .doc-modal-dialog {
  position: relative;
  max-width: 900px;
  max-height: 90vh;
  margin: 4vh auto;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
#doc-modal .doc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.02);
}

#doc-modal .doc-modal-header h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

/* Close button */
#doc-modal .doc-modal-close {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
}

#doc-modal .doc-modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Body: TOC + content */
#doc-modal .doc-modal-body {
  display: flex;
  min-height: 0;
}

/* TOC (left side) */
#doc-modal .doc-modal-toc {
  width: 220px;
  border-right: 1px solid var(--border-subtle);
  padding: 0.6rem 0.5rem;
  box-sizing: border-box;
  background: var(--bg-body);
  font-size: 0.8rem;
  overflow-y: auto;
}

#doc-modal .doc-modal-toc h3 {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

#doc-modal .doc-modal-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#doc-modal .doc-modal-toc li {
  margin: 0.1rem 0;
}

#doc-modal .doc-modal-toc a {
  display: block;
  text-decoration: none;
  padding: 0.22rem 0.35rem;
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
}

#doc-modal .doc-modal-toc a:hover {
  background: var(--bg-accent-soft);
}

#doc-modal .doc-modal-toc a.is-active {
  background: var(--bg-accent-soft);
  font-weight: 600;
}

/* Content (right side) */
#doc-modal .doc-modal-content {
  flex: 1;
  padding: 0.7rem 0.9rem 0.9rem;
  box-sizing: border-box;
  overflow-y: auto;
}

#doc-modal .doc-modal-content .doc-section + .doc-section {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-subtle);
}

#doc-modal .doc-modal-content h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

#doc-modal .doc-modal-content h4 {
  margin: 0.4rem 0 0.25rem;
  font-size: 0.88rem;
}

#doc-modal .doc-modal-content p {
  margin: 0 0 0.4rem;
  line-height: 1.4;
  color: var(--text-main);
}

#doc-modal .doc-modal-content ul {
  margin: 0 0 0.45rem 1.05rem;
  padding: 0;
}

#doc-modal .doc-modal-content li {
  margin: 0.15rem 0;
}

#doc-modal .doc-modal-content code {
  font-family: monospace;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.05rem 0.25rem;
  border-radius: 4px;
}

/* Dark theme: documentation modal */

body.dark-theme #doc-modal .doc-modal-dialog {
  background: #262626;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
  border: 1px solid #333333;
}

body.dark-theme #doc-modal .doc-modal-header {
  border-bottom-color: #333333;
  background: #1c1c1c;
}

body.dark-theme #doc-modal .doc-modal-toc {
  background: #1b1b1b;
  border-right-color: #333333;
}

body.dark-theme #doc-modal .doc-modal-toc h3 {
  color: #aaaaaa;
}

body.dark-theme #doc-modal .doc-modal-toc a {
  color: #e5e5e5;
}

body.dark-theme #doc-modal .doc-modal-toc a:hover,
body.dark-theme #doc-modal .doc-modal-toc a.is-active {
  background: rgba(144, 202, 249, 0.16);
}

body.dark-theme #doc-modal .doc-modal-content p,
body.dark-theme #doc-modal .doc-modal-content li {
  color: #e0e0e0;
}

body.dark-theme #doc-modal .doc-modal-content code {
  background: rgba(255, 255, 255, 0.06);
}


/* ================================
   Print styles
   ================================ */

@page {
  size: A4;
  margin: 12mm;
}



/* ================================
   Mobile / small screen layout
   ================================ */

@media (max-width: 768px) {
  body {
    padding: 0.5rem;
    background: var(--bg-body);
  }

  .invoice-app {
    margin: 0;
    padding: 0.5rem;
    box-shadow: none;
    border-radius: 0.5rem;
  }

  .main-layout, .editor-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .row {
    flex-direction: column;
  }

  .col-50 {
    flex: 1 1 100%;
  }
  
  /* Reset the large margin on mobile */
  #buyer-section + .premium-teaser {
    margin-top: 1rem;
  }

  /* Reset flex properties for stacked layout */
  #payment-details-section {
    flex-grow: 0;
  }

  .field-group {
    margin-bottom: 0.4rem;
  }

  .field-group label {
    font-size: 0.9rem;
  }

  input[type="text"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    font-size: 0.9rem;
    padding: 0.25rem 0.4rem;
  }

  .btn-row {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .btn-row .btn {
    flex: 1 1 48%;
    justify-content: center;
    font-size: 0.9rem;
    padding: 0.45rem 0.3rem;
  }

  .btn {
    min-height: 2.2rem;
  }

  #items-section {
    overflow-x: auto;
  }

  #items-table {
    min-width: 600px;
    font-size: 0.85rem;
  }

  #items-table th,
  #items-table td {
    padding: 0.25rem 0.35rem;
  }

  .templates-row,
  .template-row {
    flex-direction: column;
    align-items: stretch;
  }

  .template-row select,
  .template-row button {
    width: 100%;
  }

  .qr-wrapper {
    flex-direction: column;
    align-items: flex-start;
  }

  .qr-wrapper #qr-code {
    margin-bottom: 0.3rem;
  }

  .signature-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .signature-block,
  .stamp-block {
    flex: 1 1 100%;
  }
  
  /* Documentation modal: stack on mobile */
  #doc-modal .doc-modal-dialog {
    max-width: 96vw;
    margin: 2vh auto;
  }

  #doc-modal .doc-modal-body {
    flex-direction: column;
  }

  #doc-modal .doc-modal-toc {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding-bottom: 0.45rem;
  }

  #doc-modal .doc-modal-toc h3 {
    flex-basis: 100%;
    margin-bottom: 0.25rem;
  }

  #doc-modal .doc-modal-toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  #doc-modal .doc-modal-toc li {
    margin: 0;
  }

  #doc-modal .doc-modal-toc a {
    font-size: 0.78rem;
    padding: 0.16rem 0.35rem;
  }
  
  /* Stack toolbar vertically on small screens */
  .app-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    flex-wrap: wrap;          /* allow wrapping instead of forcing one row */
  }

  /* Allow right-side controls (language, theme, buttons) to wrap */
  .toolbar-right {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  /* Make buttons behave nicely when wrapped */
  .toolbar-right .btn {
    /* they can still sit two per line if there is room */
    flex: 1 1 48%;
  }

    /* Increase horizontal padding so content doesn't touch screen edge */
  .invoice-app {
    /*padding-left: 1.25rem;*/
    padding-right: 1.25rem;
  }
}

.toolbar-reset-row {
  display: flex;
  justify-content: flex-end;
  padding: 0 1rem 0.75rem;
}

.toolbar-reset-row .btn {
  font-size: 0.9rem;
}


@media print {
  body {
    background: #ffffff !important;
    padding: 0;
    margin: 0;
  }

#btn-reset-form {
  display: none !important;
}

#doc-modal {
    display: none !important;
  }

  .invoice-app {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    max-width: 100%;
  }

  .app-toolbar,
  .screen-only,
  input[type="file"],
  button,
  select,
  textarea,
  input[type="text"],
  input[type="number"],
  input[type="date"] {
    /* We will rely on a generated print layout instead of raw form */
  }

  .app-toolbar {
    display: none !important;
  }

  .editor-layout {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  .hide-on-print {
    display: none !important;
  }
}

/* ================================
   Print invoice container
   ================================ */

#print-invoice {
  display: none;
}

@media print {
  body {
    background: #ffffff !important;
    padding: 0;
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .invoice-app {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    max-width: 100%;
  }

  .app-toolbar,
  .editor-layout,
  .screen-only {
    display: none !important;
  }

  #print-invoice {
    display: block !important;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
      Roboto, sans-serif;
    font-size: 10.5pt;
    color: #111;
  }

  #print-invoice .inv-page {
    width: 100%;
    min-height: 260mm;
    box-sizing: border-box;
    padding: 18mm 20mm 20mm;
  }

  #print-invoice .inv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #cccccc;
  }

  #print-invoice .inv-block {
    font-size: 10.5pt;
  }

  #print-invoice .inv-seller,
  #print-invoice .inv-buyer {
    width: 48%;
  }

  #print-invoice .inv-logo img {
    max-height: 28px;
    max-width: 120px;
    display: block;
    margin-bottom: 6px;
  }

  #print-invoice .inv-seller h2,
  #print-invoice .inv-buyer h2 {
    margin: 0 0 4px 0;
    font-size: 11pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  #print-invoice .inv-seller div,
  #print-invoice .inv-buyer div {
    margin-bottom: 2px;
  }

  #print-invoice .inv-meta-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
  }

  #print-invoice .inv-meta {
    min-width: 40%;
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 6px 8px;
    background: #fafafa;
  }

  #print-invoice .inv-meta h2 {
    margin: 0 0 4px 0;
    font-size: 10.5pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  #print-invoice .inv-meta div {
    margin-bottom: 2px;
  }

  #print-invoice .inv-items {
    margin-top: 6px;
  }

  #print-invoice .inv-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
    font-size: 10pt;
  }
  
  #print-invoice .inv-items-table {
    page-break-inside: auto;
  }

  #print-invoice .inv-items-table tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  #print-invoice .inv-items-table thead {
    display: table-header-group;
  }

  #print-invoice .inv-items-table tfoot {
    display: table-footer-group;
  }

  #print-invoice .inv-items-table th,
  #print-invoice .inv-items-table td {
    padding: 3px 6px;
    border: 1px solid #dddddd;
  }

  #print-invoice .inv-items-table th {
    background: #f2f2f2;
    font-weight: 600;
    font-size: 9pt;
    color: #555555;
    text-align: left;
  }

  #print-invoice .inv-items-table td:nth-last-child(1),
  #print-invoice .inv-items-table td:nth-last-child(2),
  #print-invoice .inv-items-table th:nth-last-child(1),
  #print-invoice .inv-items-table th:nth-last-child(2) {
    text-align: right;
  }

  #print-invoice .inv-totals-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
  }

  #print-invoice .inv-totals {
    min-width: 40%;
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 6px 8px;
    background: #fafafa;
    font-size: 10pt;
  }

  #print-invoice .inv-totals div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
  }

  /* NEW: flex only on our explicit rows */
#print-invoice .inv-totals .inv-total-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;              /* visible space between label and amount */
}

#print-invoice .inv-total-value {
  white-space: nowrap;   /* keeps 261378555.90 EUR together */
}

  #print-invoice .inv-totals div strong {
    font-weight: 600;
  }

  #print-invoice .inv-totals div:last-child {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #000000;
    font-weight: 700;
  }

  #print-invoice .inv-reverse-charge {
    margin-top: 5px;
    font-size: 9pt;
    font-style: italic;
  }

  #print-invoice .inv-payment {
    margin-top: 10px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 9.5pt;
  }

  #print-invoice .inv-payment h2 {
    margin: 0 0 4px 0;
    font-size: 10.5pt;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  #print-invoice .inv-payment > div {
    margin-bottom: 2px;
  }

  #print-invoice .inv-qr-wrapper {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  #print-invoice .inv-qr-label {
    font-weight: 600;
    font-size: 9.5pt;
  }

  #print-invoice .inv-qr-help {
    font-size: 8.8pt;
    color: #444444;
    max-width: 220px;
  }

  #print-invoice .inv-qr-wrapper img,
  #print-invoice .inv-qr-wrapper canvas {
    width: 110px;
    height: 110px;
  }

  #print-invoice .inv-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-start;
    gap: 40px;
    font-size: 9.5pt;
  }

  #print-invoice .inv-signature-block,
  #print-invoice .inv-stamp-block {
    text-align: center;
  }

  #print-invoice .inv-signature-block img,
  #print-invoice .inv-stamp-block img {
    max-height: 40px;
    display: block;
    margin: 4px auto 0;
  }
}

/* --- Footer --- */
.site-footer {
  margin-top: 0.6rem;         /* was 1.2rem — now tighter */
  padding: 0.4rem 0 0.7rem;   /* reduced further */
  text-align: center;
  font-size: 0.88rem;         /* visually balanced */
  color: var(--text-muted);
}

.site-footer a {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover {
  text-decoration: underline;
}

.bmc-footer-button {
  display: inline-block;
  margin-top: 0.45rem;         /* less vertical spacing */
  padding: 0.28rem 1rem;       /* slightly smaller button */
  background: #ffdd00;
  border-radius: 7px;
  color: #000;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.2s ease;
}

.bmc-footer-button:hover {
  filter: brightness(0.92);
  text-decoration: none;
  color: #000;
}

.vat-label-cell label {
  display: block;
  margin-bottom: 4px;
  white-space: nowrap;
}

