/* Interface Facture Vctory */
:root {
  --ink: #0F172A;
  --action: #2563EB;
  --canvas: #F1F5F9;
  --surface: #FFFFFF;
  --muted: #64748B;
  --line: #E2E8F0;
  --success: #059669;
  --danger: #DC2626;
  --action-hover: #1D4ED8;
  --success-hover: #047857;
  --danger-hover: #B91C1C;
  --action-soft: #EFF6FF;
  --success-soft: #ECFDF5;
  --danger-soft: #FEF2F2;
  --warning: #92400E;
  --warning-soft: #FFFBEB;
  --focus: rgba(37, 99, 235, .24);
  --radius: 8px;
  --card-radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .04);
  --transition: 140ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { font-family: "Segoe UI", system-ui, sans-serif; line-height: 1.6; }
body { background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
button:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 3px;
}

.container { width: min(100% - 48px, 1460px); margin-inline: auto; padding-bottom: 8px; }
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  margin-bottom: 28px;
  padding: 10px 20px;
  color: var(--surface);
  background: var(--ink);
  border-radius: 0 0 14px 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .14);
}
.nav-brand, .nav-tab { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.nav-brand { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--action);
  border-radius: 10px;
}
.brand-mark svg { width: 21px; height: 21px; }
.nav-tabs { display: flex; min-width: 0; gap: 4px; }
.nav-tab {
  justify-content: center;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #CBD5E1;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.nav-tab svg, .form-section h3 svg, .preview-toolbar h2 svg { width: 17px; height: 17px; flex: none; }
.nav-tab:hover { color: var(--surface); background: #1E293B; }
.nav-tab.active { color: var(--surface); background: var(--action); }
.nav-tab:focus-visible { outline-color: #93C5FD; outline-offset: 1px; }
.nav-toggle {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #475569;
  border-radius: 12px;
  background: #1E293B;
  color: var(--surface);
  cursor: pointer;
}
.nav-toggle[aria-expanded="true"] { background: var(--action); border-color: var(--action); }
.nav-toggle-icon { position: relative; width: 21px; height: 18px; }
.nav-toggle-icon::before, .nav-toggle-icon::after, .nav-toggle-icon > span {
  position: absolute;
  inset: 8px 0 auto;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.nav-toggle-icon::before { content: ""; transform: translateY(-6px); }
.nav-toggle-icon::after { content: ""; transform: translateY(6px); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before { transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after { transform: rotate(-45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon > span { visibility: hidden; }
.nav-toggle:focus-visible { outline-color: #93C5FD; }
.nav-account { display: flex; align-items: center; gap: 5px; min-width: 0; color: #CBD5E1; font-size: 14px; }
.nav-account span { min-width: 0; max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-fields { width: min(100%, 400px); }
#accountEmail { margin-bottom: 12px; overflow-wrap: anywhere; }
.account-message { margin-bottom: 12px; color: var(--success-hover); }
.account-message[data-error="true"] { color: var(--danger-hover); }
#restoreBackupDialog {
  width: min(calc(100% - 24px), 560px);
  max-height: calc(100dvh - 24px);
  padding: clamp(18px, 4vw, 26px);
  margin: auto;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}
#restoreBackupDialog::backdrop { background: rgb(15 23 42 / 55%); }
#restoreBackupDialog p { margin-bottom: 12px; }
.restore-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 4px 16px; margin: 0 0 16px 18px; }
@media (max-width: 1120px) {
  .navbar { flex-wrap: wrap; }
  .nav-account { margin-left: auto; }
  .nav-tabs { order: 1; flex-wrap: wrap; width: 100%; }
}
.main-content { display: grid; grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr); align-items: start; gap: 24px; }
.section {
  min-width: 0;
  padding: clamp(18px, 2.5vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.section h2, .modal h2 {
  margin-bottom: 20px;
  font-size: clamp(21px, 2.1vw, 28px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.035em;
}
.form-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 16px;
  line-height: 1.35;
}
.form-section h3 svg { color: var(--action); }
.form-group { min-width: 0; margin-bottom: 13px; }
.form-row { display: flex; flex-wrap: wrap; column-gap: 14px; }
.form-row > .form-group { flex: 1 1 210px; }
.invoice-reference > .form-group { flex-basis: 135px; margin-bottom: 0; }
.form-group label, .invoice-article label, .payment-details label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 600; }
.form-group small, .article-ht, #amountInWords, .modal-body { color: var(--muted); font-size: 13px; }
.form-group small { display: block; margin-top: 5px; }
.required { color: var(--danger); }

.container :is(input:not([type="checkbox"], [type="radio"]), select) {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.container :is(input:not([type="checkbox"], [type="radio"]), select):hover:enabled { border-color: #94A3B8; }
.container :is(input:not([type="checkbox"], [type="radio"]), select):focus {
  outline: none;
  border-color: var(--action);
  box-shadow: 0 0 0 3px var(--focus);
}
.container input[readonly] { background: var(--canvas); color: #475569; }
.container :is(input, select):disabled { opacity: .58; cursor: not-allowed; }
.container input::placeholder { color: var(--muted); opacity: 1; }
.container input:is([type="checkbox"], [type="radio"]) {
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--action);
}
.container input:is([type="checkbox"], [type="radio"]):focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }
.payment-options, .price-buttons, .form-actions, .modal-footer, .client-actions, .bottom-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.payment-option, .reset-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.payment-option:has(input:checked) { border-color: #BFDBFE; background: var(--action-soft); }
.payment-status, .payment-details { margin-top: 12px; }
.payment-details { max-width: 240px; }
.cheque-details, .virement-details, .versement-details { display: none; }

:is(.btn-primary, .btn-secondary, .btn-danger, .price-btn, .history-action) {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 39px;
  padding: 8px 12px;
  border: 1px solid var(--button-border, var(--line));
  border-radius: var(--radius);
  background: var(--button-bg, var(--surface));
  color: var(--button-text, var(--ink));
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
:is(.btn-primary, .btn-secondary, .btn-danger, .price-btn, .history-action) svg { width: 15px; height: 15px; flex: none; }
:is(.btn-primary, .btn-secondary, .btn-danger, .price-btn, .history-action):hover:enabled {
  background: var(--button-hover, var(--canvas));
}
:is(.btn-primary, .btn-secondary, .btn-danger, .price-btn, .history-action):active:enabled { filter: brightness(.93); }
:is(.btn-primary, .btn-secondary, .btn-danger, .price-btn, .history-action):disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { --button-bg: var(--action); --button-border: var(--action); --button-hover: var(--action-hover); --button-text: var(--surface); }
.btn-save, .btn-save.btn-primary {
  --button-bg: var(--success-hover);
  --button-border: var(--success-hover);
  --button-hover: #065F46;
}
.btn-danger { --button-bg: var(--danger); --button-border: var(--danger); --button-hover: var(--danger-hover); --button-text: var(--surface); }
.price-btn:is(.selected, .other) { --button-bg: var(--action-soft); --button-border: #BFDBFE; --button-text: var(--action-hover); }
.form-wrapper > .form-actions { margin-top: 16px; }
.bottom-buttons { width: min(100% - 48px, 1460px); margin: 12px auto 24px; justify-content: flex-end; }
.print-settings-hint { flex-basis: 100%; color: var(--muted); font-size: 12px; text-align: right; }

.calculated-values { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
.calculated-row { display: flex; justify-content: space-between; gap: 14px; padding: 3px 0; font-size: 13px; }
.calculated-row span:first-child { color: var(--muted); }
.calculated-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.calculated-row.total-row { margin-top: 7px; padding-top: 9px; border-top: 1px solid var(--line); font-size: 17px; }
.calculated-row.total-row span { color: var(--ink); font-weight: 700; }
.warning-box, .history-warning, #invoiceEditNotice, #clientEditMessage:not(:empty), #dataResetMessage:not(:empty) {
  padding: 10px 12px;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
}
.warning-box { align-items: flex-start; gap: 8px; margin: 12px 0; }
.warning-icon { width: 18px; height: 18px; flex: none; }
#invoiceEditNotice, #dataResetMessage:not(:empty) { margin-top: 12px; }
#clientEditMessage:not(:empty) { border-color: #FECACA; background: var(--danger-soft); color: var(--danger-hover); margin-bottom: 12px; }

.invoice-preview { padding: 0; background: #E8EEF6; }
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.invoice-preview > .preview-toolbar { border-radius: var(--card-radius) var(--card-radius) 0 0; }
.preview-toolbar h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: 16px; letter-spacing: -.015em; }
.preview-toolbar span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.preview-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#invoicePreview { display: flex; justify-content: center; min-width: 0; padding: clamp(10px, 1.8vw, 24px); }
#invoicePreviewPaper {
  position: relative;
  flex: none;
  /* A transform does not shrink the original scrollable bounds of the page. */
  overflow: clip;
}
#invoicePreviewPaper, .preview-full-size > .a4-invoice-page { background: #fff; box-shadow: 0 5px 16px rgba(15, 23, 42, .11); }
#invoicePreviewPaper > .a4-invoice-page {
  position: absolute;
  inset: 0 auto auto 0;
  transform: scale(var(--invoice-preview-scale, 1));
  transform-origin: top left;
}
#invoicePreviewDialog {
  width: min(900px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  color: var(--ink);
  background: #E8EEF6;
}
#invoicePreviewDialog[open] { display: flex; flex-direction: column; }
#invoicePreviewDialog::backdrop { background: rgba(15, 23, 42, .58); }
.preview-full-size { overflow: auto; min-height: 0; padding: 12px; }
.preview-full-size .a4-invoice-page { margin-inline: auto; }

.history-table-scroll, .client-table-wrapper { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
:is(.history-table-scroll, .client-table-wrapper) table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
:is(.history-table-scroll, .client-table-wrapper) :is(th, td) { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
:is(.history-table-scroll, .client-table-wrapper) th { color: #475569; background: var(--canvas); font-weight: 650; white-space: nowrap; }
:is(.history-table-scroll, .client-table-wrapper) tbody tr:last-child td { border-bottom: 0; }
:is(.history-table-scroll, .client-table-wrapper) tbody tr:hover { background: #F8FAFC; }
.history-table-scroll :is(td:nth-child(-n+2), td:nth-child(n+4):nth-child(-n+8)), .client-table-wrapper td:nth-child(2) {
  font-variant-numeric: tabular-nums;
}
@media (min-width: 681px) {
  .history-table-scroll :is(td:nth-child(-n+2), td:nth-child(n+4):nth-child(-n+8)), .client-table-wrapper td:nth-child(2) { white-space: nowrap; }
  .history-table-scroll :is(th, td):nth-child(n+5):nth-child(-n+8) { text-align: right; }
}
.mobile-cell-label { display: none; }
.cell-value { display: contents; }
@media (min-width: 681px) and (max-width: 1120px) {
  .history-table-scroll td:nth-child(3), .client-table-wrapper td:first-child { min-width: 16ch; }
}
.history-actions { display: flex; flex-wrap: wrap; gap: 4px; min-width: 190px; max-width: 258px; }
.history-action { min-height: 27px; padding: 3px 6px; gap: 4px; font-size: 12px; white-space: nowrap; }
.history-action svg { width: 13px; height: 13px; }
.history-action.danger, .remove-article {
  --button-bg: var(--danger-soft);
  --button-text: var(--danger-hover);
  --button-border: #FECACA;
  --button-hover: #FEE2E2;
}
.history-badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.history-badge.paid { color: var(--success-hover); background: var(--success-soft); }
.history-badge.unpaid { color: var(--warning); background: var(--warning-soft); }
.history-badge.cancelled { color: var(--danger-hover); background: var(--danger-soft); }
.history-badge.draft { color: #475569; background: var(--canvas); }
#invoicesTableBody details { margin-top: 4px; color: var(--muted); }
#invoicesTableBody summary { cursor: pointer; }
.history-warning { margin-bottom: 14px; }
.search-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.search-filter .search-field { flex: 1 1 260px; }
.container .search-filter select { width: auto; min-width: 145px; }
.search-field { position: relative; max-width: 420px; }
.search-field > svg { position: absolute; left: 11px; top: 12px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.container .search-field input { padding-left: 34px; }
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}
.empty-state svg { width: 23px; height: 23px; color: var(--action); }

.client-autocomplete { position: relative; }
.client-suggestions {
  position: absolute;
  inset: calc(100% + 5px) 0 auto;
  z-index: 10;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
}
.client-suggestions button {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.client-suggestions button span { color: var(--muted); }
.client-suggestions button:is(:hover, :focus-visible) { background: var(--action-soft); outline-offset: -2px; }

.invoice-article { min-width: 0; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #F8FAFC; }
.article-fields { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 10px; }
.article-fields label { min-width: 0; }
.article-quantity-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: end; }
.article-quantity-field label { margin-bottom: 0; }
.article-ht { margin: 6px 0; }
.article-ht output { color: var(--ink); font-weight: 650; }
#addArticleBtn { margin: 3px 0 14px; }
#amountInWords { margin-top: 3px; }
.settings-section > form, .settings-section > .form-section { max-width: 860px; }
.settings-section .reset-options { display: grid; justify-items: start; gap: 5px; margin-top: 12px; }
.reset-options label { display: inline-flex; margin: 0; font-weight: 500; }
#resetConfirmation, #resetInvoiceYear { max-width: 240px; }
.settings-section > .form-section > p { color: var(--muted); font-size: 14px; }

.modal { position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .58); }
.modal-content, #clientEditDialog {
  width: min(100%, 520px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: clamp(16px, 4vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 48px rgba(15, 23, 42, .23);
}
#clientEditDialog { width: min(440px, calc(100% - 32px)); margin: auto; }
#clientEditDialog::backdrop { background: rgba(15, 23, 42, .58); }
.modal-header { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.modal-header h2 { margin: 0; }
.modal-header svg { flex: none; color: var(--success); }
.invoice-summary-box { margin: 14px 0; padding: 12px; border-radius: var(--radius); background: var(--canvas); color: var(--ink); }
.modal-footer { justify-content: flex-end; }
.notification-container { position: fixed; inset: auto 18px 18px auto; z-index: 1100; display: grid; gap: 8px; width: min(370px, calc(100% - 36px)); pointer-events: none; }
.notification {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--notice-color, var(--action));
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.notification svg { width: 17px; height: 17px; flex: none; margin-top: 2px; color: var(--notice-color, var(--action)); }
.notification.success { --notice-color: var(--success); }
.notification.warning { --notice-color: var(--warning); }
.notification.error { --notice-color: var(--danger); }

@media (max-width: 1024px) {
  .main-content { grid-template-columns: minmax(0, 1fr); }
  .bottom-buttons { justify-content: flex-start; }
  .print-settings-hint { text-align: left; }
}
@media (max-width: 680px) {
  .container, .bottom-buttons { width: calc(100% - 24px); }
  .navbar { position: static; gap: 8px; margin-bottom: 16px; min-height: 0; padding: 7px 10px; }
  .nav-toggle { display: inline-grid; }
  .nav-toggle[aria-expanded="false"] ~ :is(.nav-tabs, .nav-account) { display: none; }
  .nav-tabs { order: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 4px; }
  .nav-account { width: 100%; margin-left: 0; justify-content: space-between; border-top: 1px solid #334155; padding: 5px 0 0 8px; }
  .nav-account span { max-width: none; overflow-wrap: anywhere; white-space: normal; }
  .nav-tab { justify-content: flex-start; min-width: 0; padding-inline: 8px; font-size: 13px; white-space: normal; text-align: left; }
  .nav-brand { font-size: 17px; }
  .brand-mark { width: 31px; height: 31px; }
  .main-content { gap: 16px; }
  .section { padding: 16px; }
  .invoice-preview { padding: 0; }
  .preview-toolbar { flex-wrap: wrap; padding: 10px 12px; }
  .invoice-reference { row-gap: 10px; }
  .container :is(input:not([type="checkbox"], [type="radio"]), select) { font-size: 16px; min-height: 44px; }
  .container .search-filter select { width: 100%; min-width: 0; }
  .search-filter .search-field { max-width: none; }
  :is(.history-table-scroll, .client-table-wrapper) { border: 0; border-radius: 0; overflow: visible; }
  :is(.history-table-scroll, .client-table-wrapper) :is(table, tbody, tr) { display: block; }
  :is(.history-table-scroll, .client-table-wrapper) thead { position: absolute; width: 1px; height: 1px; overflow: clip; clip-path: inset(50%); }
  :is(.history-table-scroll, .client-table-wrapper) tbody tr {
    margin-bottom: 10px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  :is(.history-table-scroll, .client-table-wrapper) tbody td {
    display: grid;
    grid-template-columns: minmax(0, 7.25rem) minmax(0, 1fr);
    align-items: baseline;
    gap: 4px 8px;
    padding: 6px 2px;
    white-space: normal;
    text-align: left;
  }
  :is(.history-table-scroll, .client-table-wrapper) tbody tr:last-child td:not(:last-child) { border-bottom: 1px solid var(--line); }
  :is(.history-table-scroll, .client-table-wrapper) tbody td:last-child { grid-template-columns: minmax(0, 1fr); border: 0; }
  .mobile-cell-label { display: block; color: #475569; font-weight: 650; }
  .cell-value { display: block; min-width: 0; }
  .client-actions > .cell-value { display: flex; flex-wrap: wrap; gap: 4px; }
  .history-actions { min-width: 0; max-width: none; }
  :is(.nav-tab, .btn-primary, .btn-secondary, .btn-danger, .price-btn, .history-action, .payment-option, .reset-options label) { min-height: 44px; }
  :is(.modal-footer, dialog .form-actions, dialog .client-actions) > button { flex: 1 1 160px; }
}
@media (max-width: 480px) {
  .article-fields { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 390px) {
  .calculated-row { flex-wrap: wrap; gap: 4px 10px; }
}
.calculated-row span:last-child { white-space: normal; }
:is(.section, .modal-content, .notification) { overflow-wrap: anywhere; }
.notification > * { min-width: 0; }
@media (prefers-reduced-motion: reduce) {
  :root { --transition: 0ms; }
}

/* Facture A4, valeurs conservées pour l’aperçu et l’impression. */

.a4-invoice-page {
  font-family: 'Segoe UI', sans-serif;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.6;
  color: #2c3e50;
  --border-color: #e0e0e0;
}

:is(#invoicePreview, .preview-full-size) .a4-invoice-page {
  display: flex;
  flex: none;
  flex-direction: column;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm;
}

.invoice-company-name {
  margin-bottom: 20px;
  text-align: center;
  font-size: 22px;
  font-weight: bold;
}

.invoice-identification {
  margin-bottom: 25px;
  text-align: right;
  font-size: 14px;
}

.invoice-title { font-size: 24px; font-weight: bold; }
.invoice-customer { padding-top: 16px; border-top: 1px solid var(--border-color); font-size: 14px; }
.invoice-customer strong { display: block; margin-bottom: 10px; }
.invoice-articles-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.invoice-articles-table :is(th, td) { padding: 8px; text-align: left; font-size: 13px; }
.invoice-articles-table th { background-color: #f8f9fa; color: #2c3e50; font-weight: 600; }
.invoice-articles-table td { border-bottom: 1px solid #e0e0e0; }
.invoice-articles-table :is(th, td):nth-child(2) { text-align: center; }
.invoice-articles-table :is(th, td):last-child { text-align: right; }
.invoice-totals { padding-top: 14px; border-top: 2px solid var(--border-color); font-size: 14px; }
.invoice-totals > div { display: flex; justify-content: space-between; margin-bottom: 8px; }
.invoice-tax { color: #e74c3c; }
.invoice-grand-total { padding-top: 8px; border-top: 1px solid var(--border-color); font-size: 18px; font-weight: bold; }
.invoice-amount-sentence { margin-top: max(8px, calc(8px + 45mm - var(--invoice-closing-reduction, 0px))); }
.invoice-payment-sentence { margin-top: 4px; }
.invoice-end { padding-top: 5mm; }
:is(#invoicePreview, .preview-full-size) .invoice-end { display: flex; flex: 1; flex-direction: column; }
:is(#invoicePreview, .preview-full-size) .invoice-legal-footer { margin-top: auto; }
.invoice-stamp { min-height: 28mm; text-align: right; font-size: 12px; }
.invoice-legal-footer {
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  white-space: pre-line;
  font-size: 12px;
  color: #555;
}

#printArea {
  display: none;
  /* A4 leaves 267 mm between the page margins. Reserve 5 mm for print layout differences. */
  --print-content-height: 262mm;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
#printArea.print-measure {
  display: block;
  position: absolute;
  inset: 0 auto auto 0;
  visibility: hidden;
  width: 180mm;
  height: var(--print-content-height);
}
#printArea .a4-invoice-page { display: flow-root; }
#printArea .invoice-legal-footer { margin-top: var(--print-footer-offset, 0px); }

@page { size:A4 portrait; margin:15mm; }
@media print {
  html, body { margin:0 !important; padding:0 !important; background:white !important; }
  body > :not(#printArea) { display:none !important; }
  #printArea { display:block !important; width:180mm; max-width:100%; margin-inline:auto; }
  .invoice-articles-table thead { display:table-header-group; }
  .invoice-articles-table tr, .invoice-heading, .invoice-totals, .invoice-end {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  #printArea * { color:black !important; box-shadow:none !important; }
}
