:root {
  --doc-orange: #f29f3f;
  --doc-cyan: #00acc1;
  --doc-gris: #e2e8f0;
  --doc-gris-clair: #f1f5f9;
  --doc-gris-fonce: #cbd5e1;
  --doc-ambre: #fbbf24;
  --doc-ambre-texte: #d97706;
}
.tab { padding: .45rem .8rem; border-radius: .5rem; color: #cbd5e1; }
.tab:hover { background: #1e293b; color: #fff; }
.tab.on { background: #4f46e5; color: #fff; }
.card { background: #fff; border-radius: .75rem; padding: 1rem; box-shadow: 0 1px 2px rgb(0 0 0 / .06); border: 1px solid #e2e8f0; }
.inp { width: 100%; border: 1px solid #cbd5e1; border-radius: .45rem; padding: .45rem .6rem; font-size: .875rem; background: #fff; }
.inp:focus { outline: 2px solid #6366f1; outline-offset: -1px; }
.lbl { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: #475569; }
.btn, .btn-primary { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: .5rem; font-size: .875rem; font-weight: 600; }
.btn { border: 1px solid #cbd5e1; background: #fff; }
.btn:hover { background: #f1f5f9; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.h2 { font-weight: 700; font-size: 1rem; display: flex; gap: .5rem; align-items: center; }
.kpi { display: flex; align-items: center; gap: 1rem; }
.kpi > i { font-size: 1.8rem; }
.kpi-v { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.kpi-l { font-size: .8rem; color: #64748b; }
.tbl { width: 100%; font-size: .875rem; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; color: #64748b; padding: .5rem; border-bottom: 1px solid #e2e8f0; }
.tbl td { padding: .5rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.icon-btn { padding: .3rem .5rem; border-radius: .4rem; color: #475569; }
.icon-btn:hover { background: #f1f5f9; }
.icon-btn.danger { color: #dc2626; }

/* ligne de saisie */
.line { display: grid; grid-template-columns: 1fr 70px 70px 100px 72px 90px 28px; gap: .35rem; align-items: center; }
.line .tot { font-size: .8rem; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .line { grid-template-columns: 1fr 1fr 1fr; } }

/* Aperçu A4 (210 x 297 mm), réduit à l'écran */
.a4-wrap { width: calc(210mm * var(--z, .72)); height: calc(297mm * var(--z, .72)); }
.a4 { width: 210mm; height: 297mm; background: #ffffff; box-shadow: 0 4px 24px rgb(0 0 0 / .15); transform: scale(var(--z, .72)); transform-origin: top left; overflow: hidden; position: relative; color: #0f172a; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
#a4-inner { padding: 15mm 12mm 12mm 12mm; transform-origin: top left; font-size: 10pt; line-height: 1.35; }
.doc-logo { width: 55mm; height: 24mm; object-fit: contain; margin-bottom: 2mm; }
.doc-company { font-weight: 800; font-size: 11pt; margin-bottom: 2mm; }
.doc-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; margin-top: 4mm; margin-bottom: 6mm; align-items: start; }
.doc-ref-box { width: 72mm; }
.doc-ref-title { background: #e2e8f0; padding: 1.5mm 3mm; font-weight: 900; text-transform: uppercase; font-size: 10pt; color: #0f172a; }
.doc-ref-date { padding: 1mm 3mm; font-weight: 700; font-size: 9pt; color: #0f172a; }
.doc-client-box { width: 72mm; margin-left: auto; border: 1px solid #cbd5e1; box-shadow: 0 1px 2px rgb(0 0 0 / .05); }
.doc-client-title { background: #f29f3f; color: #ffffff; padding: 1.5mm; text-align: center; font-weight: 700; letter-spacing: 2pt; font-size: 9pt; text-transform: uppercase; }
.doc-client-name { background: #ffffff; padding: 2.5mm; text-align: center; font-weight: 800; font-size: 11pt; color: #0f172a; }
.doc-client-ice { background: #f1f5f9; padding: 1.5mm; text-align: center; font-weight: 700; font-size: 9pt; color: #0f172a; font-family: inherit; border-top: 1px solid #e2e8f0; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 9pt; margin-top: 8mm; margin-bottom: 6mm; }
.doc-table th { background: #f29f3f; color: #ffffff; padding: 2.5mm 3mm; text-align: left; font-weight: 700; }
.doc-table td { padding: 2mm 3mm; vertical-align: top; font-weight: 600; border-bottom: 1px solid #f1f5f9; }
.doc-table .r { text-align: right; white-space: nowrap; }
.doc-table .c { text-align: center; }
.doc-totals { width: 40%; margin-left: auto; margin-top: 1mm; font-size: 9pt; display: flex; flex-direction: column; gap: 1mm; }
.doc-totals > div { display: flex; justify-content: space-between; padding: 1.5mm 2mm; font-weight: 700; background: #f1f5f9; color: #0f172a; }
.doc-totals .ttc { background: #cbd5e1; font-weight: 900; font-size: 11pt; }
.doc-totals span:last-child { font-size: 10pt; text-align: right; }
.doc-totals .ttc span:last-child { font-size: 11pt; }
.doc-words { margin-top: 5mm; font-size: 9.5pt; }
.doc-payment { margin-top: 3mm; font-size: 9.5pt; }
.doc-payment .bg { background: var(--doc-gris-clair); padding: 1mm 2mm; font-weight: 700; margin-left: 2mm; }
.doc-sign { display: flex; justify-content: flex-end; margin-top: 6mm; }
.doc-sign img { max-height: 45mm; max-width: 60mm; object-fit: contain; }
.doc-foot-new { position: absolute; left: 0; right: 0;bottom: 0; padding-bottom: 15px; background: #ffffff; display: flex; flex-direction: column; font-family: Arial, Helvetica, sans-serif; }
.doc-legals { text-align: center; font-weight: 700; font-size: 8pt; border-bottom: 1px solid #64748b; padding-bottom: 2mm; margin: 0 14mm 1mm; color: #0f172a; }
.doc-legals > div { margin-bottom: 0.5mm; }
.doc-legals .doc-legal-lbl { color: #0f172a; }
.doc-legal-item { white-space: nowrap; }
.doc-foot-company { text-align: center; font-size: 8pt; margin: 0 14mm 2mm; white-space: pre-line; color: #0f172a; }
.doc-foot-cyan { background: linear-gradient(90deg, #0b2a5b, #00b4d8); color: #ffffff; font-weight: 700; font-size: 8.5pt; display: flex; justify-content: center; align-items: center; gap: 8mm; padding: 2.5mm 14mm; }
.doc-foot-cyan .fa-icon { display: inline-flex; justify-content: center; align-items: center; color: #ffffff; margin-right: 1.5mm; font-size: 9pt; }

.btn-green { background: #059669; }
.btn-green:hover { background: #047857; }

[dir=rtl] .text-left { text-align: right; }
[dir=rtl] .text-right { text-align: left; }
[dir=rtl] #toast { left: 1rem; right: auto; }
[dir=rtl] header i, [dir=rtl] .btn i, [dir=rtl] .btn-primary i, [dir=rtl] .btn-green i { margin-left: 0.4rem; margin-right: 0; }
[dir=rtl] #a4 { direction: ltr; }
/* searchPicker */
.sp-list { position: absolute; z-index: 50; width: 100%; max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: .45rem; box-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1); margin-top: .25rem; padding: .25rem 0; }
.sp-item { padding: .5rem .75rem; cursor: pointer; min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.sp-item:hover, .sp-active { background: #f1f5f9; }
.sp-item mark { background: #fde047; color: #000; padding: 0; }
[dir=rtl] .sp-item { text-align: right; }
