/* =========================================================
   CRM AW91 - Interface & documents commerciaux
   Version nettoyee : ecran, mobile, impression et html2pdf
   ========================================================= */

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #172033;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --nav: #0f172a;
    --nav-soft: #1e293b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

h1, h2, h3, h4 { color: #0f172a; }
h1 { margin: 0 0 18px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.5px; }
h2, h3 { margin-top: 0; }
p { line-height: 1.55; }

/* =========================================================
   SIDEBAR
   ========================================================= */

aside {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    height: 100vh;
    padding: 22px 18px;
    background: linear-gradient(180deg, #0f172a 0%, #111c31 100%);
    color: #fff;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 8px 0 30px rgba(15, 23, 42, .08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 62px;
    margin-bottom: 22px;
    padding: 0 4px 18px;
    border-bottom: 1px solid rgba(255,255,255,.09);
}

.brand img {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    object-fit: contain;
    padding: 4px;
    background: #fff;
    border-radius: 12px;
}

.brand h3 { margin: 0; color: #fff; font-size: 16px; }
.brand small { display: block; margin-top: 3px; color: #94a3b8; font-size: 11px; }

.sidebar-nav { display: grid; gap: 4px; }

nav a,
.link {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 43px;
    padding: 10px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

nav a i,
.link i { width: 18px; text-align: center; color: #93c5fd; }

nav a:hover,
.link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    transform: translateX(2px);
}

.sidebar-nav form { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.08); }
.menu-toggle { display: none; }

/* =========================================================
   LAYOUT
   ========================================================= */

.with-sidebar { margin-left: 248px; }

main {
    min-height: 100vh;
    padding: 30px;
}

main.with-sidebar > :not(.document):not(.public-document) {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.head h1,
.head h2 { margin-bottom: 0; }
.head p { margin: 5px 0 0; color: var(--muted); }

.panel,
section,
.card,
.login {
    background: var(--surface);
    border: 1px solid rgba(226,232,240,.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel,
section { padding: 22px; margin-bottom: 20px; }

.app-footer {
    padding: 22px 0 8px;
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
}

.app-footer a { color: #64748b; text-decoration: none; }

/* =========================================================
   BOUTONS
   ========================================================= */

.button,
button,
.btn-print,
.btn-back,
.btn-secondary,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
}

.button:hover,
button:hover,
.btn-print:hover,
.btn-back:hover,
.btn-secondary:hover,
.btn-danger:hover {
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(37,99,235,.16);
}

button:disabled { opacity: .58; cursor: wait; transform: none; box-shadow: none; }

.secondary,
.btn-secondary,
.btn-back {
    background: #fff;
    color: #334155;
    border-color: #cbd5e1;
}

.secondary:hover,
.btn-secondary:hover,
.btn-back:hover { color: #0f172a; background: #f8fafc; box-shadow: 0 6px 16px rgba(15,23,42,.08); }

.danger,
.btn-danger { background: var(--danger); color: #fff; }
.small { min-height: 31px; padding: 6px 9px; font-size: 12px; border-radius: 7px; }
.inline { display: inline-flex; margin-left: 6px; }
.whatsapp { background: #16a34a; }

.document-toolbar { max-width: 210mm !important; margin: 0 auto 14px !important; }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* =========================================================
   FORMULAIRES
   ========================================================= */

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.full { grid-column: 1 / -1; }

label {
    display: block;
    margin-bottom: 13px;
    color: #334155;
    font-weight: 700;
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    margin-top: 6px;
    padding: 9px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea { min-height: 95px; resize: vertical; }
input:focus,
select:focus,
textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
input[readonly] { background: #f8fafc; color: #475569; }

.price-input,
.qty-input,
.price,
.qty,
.tax { text-align: right; }

.totalbox {
    margin: 18px 0;
    padding: 14px 16px;
    text-align: right;
    font-size: 17px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
}

/* =========================================================
   TABLEAUX
   ========================================================= */

.table-wrap { width: 100%; overflow-x: auto; border-radius: 11px; }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    font-size: 13px;
}

main > table,
.panel > table {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 11px;
    box-shadow: 0 6px 20px rgba(15,23,42,.04);
}

th,
td {
    padding: 12px 13px;
    border-bottom: 1px solid #e9eef5;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .35px;
    text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:not(.empty-space):hover td { background: #fbfdff; }
td a { font-weight: 700; text-decoration: none; }

#lines,
#bl-items-table { margin: 10px 0 14px; }
#lines input,
#lines select,
#bl-items-table input,
#bl-items-table select { min-width: 80px; margin-top: 0; }
#lines .desc { min-width: 180px; }
#bl-items-table input[name="description[]"] { min-width: 180px; }
.line-total { white-space: nowrap; font-weight: 700; }

/* =========================================================
   BADGES & ALERTES
   ========================================================= */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    text-transform: capitalize;
}

.status-paid,
.status-invoiced,
.status-converted,
.status-delivered { background: #dcfce7; color: #166534; }
.status-draft { background: #e0f2fe; color: #075985; }
.status-partial,
.status-unpaid { background: #fef3c7; color: #92400e; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

.alert {
    padding: 13px 15px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
}
.success { background: #ecfdf5; border-color: #bbf7d0; color: #166534; }
.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.muted { color: var(--muted); }
.empty { padding: 25px; color: #94a3b8; text-align: center; }

/* =========================================================
   DASHBOARD
   ========================================================= */

.dashboard-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 26px 28px;
    margin-bottom: 20px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 14px 34px rgba(30,64,175,.18);
}

.dashboard-hero h1 { margin: 2px 0 7px; color: #fff; font-size: 30px; }
.dashboard-hero p { margin: 0; color: #dbeafe; }
.eyebrow { font-size: 11px !important; font-weight: 800; letter-spacing: 1.4px; color: #93c5fd !important; }
.hero-date { padding: 10px 14px; border: 1px solid rgba(255,255,255,.16); border-radius: 10px; background: rgba(255,255,255,.09); white-space: nowrap; font-weight: 700; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card {
    position: relative;
    overflow: hidden;
    padding: 20px;
    background: #fff;
    border: 1px solid #edf1f6;
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(15,23,42,.05);
}
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); }
.metric-card.warning::before { background: #f59e0b; }
.metric-card span,
.metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; margin: 8px 0; color: #0f172a; font-size: 25px; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.dashboard-grid.two-thirds { grid-template-columns: 3fr 2fr; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.section-title a { font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.chart-panel { min-height: 300px; }
.bars { height: 225px; display: flex; align-items: flex-end; gap: 18px; padding: 20px 12px 0; border-bottom: 1px solid var(--border); }
.bar-item { height: 100%; flex: 1; min-width: 55px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar { width: 68%; max-width: 54px; min-height: 8px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg,#60a5fa,#2563eb); }
.bar-value { margin-bottom: 6px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.bar-item b { margin-top: 8px; color: #475569; font-size: 10px; }
.compact-list > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #eef2f7; }
.compact-list span b,
.compact-list span small { display: block; }
.compact-list small { margin-top: 3px; color: var(--muted); }
.compact-list > div > strong { padding: 5px 9px; border-radius: 999px; background: #fee2e2; color: #b91c1c; }

/* =========================================================
   PARAMETRES & LOGIN
   ========================================================= */

.settings-layout { display: grid; grid-template-columns: 260px minmax(0,1fr); gap: 28px; }
.logo-box { padding: 18px; border: 1px dashed #cbd5e1; border-radius: 12px; background: #fbfdff; }
.logo-box img { display: block; width: 100%; height: 140px; margin: 12px 0; padding: 8px; object-fit: contain; border-radius: 9px; background: #fff; border: 1px solid #eef2f7; }
.logo-placeholder { height: 140px; display: flex; align-items: center; justify-content: center; margin: 12px 0; border-radius: 9px; background: #f1f5f9; color: #94a3b8; }
.logo-box small { display: block; margin-top: 7px; color: var(--muted); }
.remove-logo { font-size: 12px; font-weight: 500; }
.remove-logo input { width: auto; min-height: 0; margin-right: 6px; }

.login {
    width: min(440px, calc(100% - 32px));
    margin: 8vh auto;
    padding: 32px;
    text-align: left;
}
.login-logo-wrap { display: flex; justify-content: center; margin-bottom: 18px; }
.login-logo { display: block; width: auto !important; max-width: 230px; max-height: 110px; object-fit: contain; }
.login h1 { margin-bottom: 6px; text-align: center; }
.login > p { margin: 0 0 24px; color: var(--muted); text-align: center; }
.login button { width: 100%; margin-top: 4px; }

/* =========================================================
   PARTAGE
   ========================================================= */

.actions,
.share-row,
.signature { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.actions { flex-wrap: wrap; }
.actions form { margin: 0; }
.share-row input { margin: 0; }
.public-document { padding: 28px; }
.public-document .document { max-width: 210mm; }

/* =========================================================
   DOCUMENTS A4 - ECRAN
   ========================================================= */

.document {
    width: 100%;
    max-width: 210mm;
    margin: 0 auto 22px;
    padding: 10mm 8mm 7mm;
    background: #fff;
    color: #222;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 16px 45px rgba(15,23,42,.12);
}

.devis-katruck,
.facture-katruck,
.bl-katruck {
    position: relative;
    min-height: 297mm;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10px;
    text-transform: uppercase;

}

.quote-logo {
    height: 34mm;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.quote-logo img { max-width: 100mm; max-height: 29mm; width: auto; height: auto; object-fit: contain; }
.quote-separator { height: 1px; margin-bottom: 7mm; background: #64748b; }
.quote-title { width: 58%; margin: 0 auto 5mm; padding: 2.6mm 5mm; border-top: 1px solid #64748b; border-bottom: 1px solid #64748b; text-align: center; }
.quote-title span { font-size: 16px; font-weight: 800; letter-spacing: .25px; }

.quote-meta { min-height: 19mm; display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0; }
.quote-date { width: 30%; padding-top: 3mm; font-size: 12px; }
.quote-client { width: 55%; border: 1px solid #94a3b8; font-size: 10px;text-transform: uppercase; }
.client-row { min-height: 6mm; display: flex; align-items: center; padding: 1mm 2mm; border-bottom: 1px solid #cbd5e1; }
.client-row:last-child { border-bottom: 0; }

.katruck-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border: 1px solid #64748b;
    border-radius: 0;
    box-shadow: none;
    text-transform: uppercase;

}
.katruck-table thead th { height: 8mm; padding: 1.3mm 1mm; border: 1px solid #64748b; background: #f8fafc; color: #1e293b; text-align: center; vertical-align: middle; font-size: 10px;    text-transform: uppercase;letter-spacing: 0; }
.katruck-table tbody td { height: 7mm; padding: 1.2mm 1.3mm; border-left: 1px solid #64748b; border-right: 1px solid #64748b; border-bottom: 0; background: #fff !important; vertical-align: top; }
.katruck-table .designation { width: 45%; text-align: left; }
.katruck-table .unit { width: 8%; text-align: center; }
.katruck-table .qty { width: 9%; text-align: center; }
.katruck-table .pu { width: 12%; text-align: right; }
.katruck-table .tva { width: 8%; text-align: center; }
.katruck-table .remise { width: 7%; text-align: center; }
.katruck-table .total-ht { width: 14%; text-align: right; }
.katruck-table .empty-space td { height: 78mm; border-top: 0; border-bottom: 1px solid #64748b; }

.signature-area { position: absolute; left: 62mm; top: 155mm; width: 48mm; height: 32mm; display: flex; align-items: center; justify-content: center; transform: rotate(-8deg); pointer-events: none; }
.signature-area img { max-width: 48mm; max-height: 32mm; }

.quote-bottom { display: flex; width: 100%; border-left: 1px solid #64748b; border-right: 1px solid #64748b; border-bottom: 1px solid #64748b; }
.amount-words { width: 65%; min-height: 24mm; padding: 3mm; border-right: 1px solid #64748b; font-size: 12px; }
.amount-words .words { margin-top: 2mm; font-weight: 500; text-transform: uppercase; }
.quote-totals { width: 35%; }
.total-line { min-height: 5mm; display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 0 2mm; border-bottom: 1px solid #cbd5e1; font-size: 10px; }
.total-line:last-child { border-bottom: 0; }
.total-line strong { text-align: right; white-space: nowrap; }
.total-line.final { min-height: 6mm; background: #f8fafc; font-size: 10px; font-weight: 800; }

.quote-footer { margin-top: 2mm; padding-top: 1.5mm; border-top: 1px solid #64748b; font-family: Georgia, "Times New Roman", serif; font-size: 7.5px; font-style: italic; text-align: center; }
.footer-info { margin-top: 1.5mm; display: flex; justify-content: center; flex-wrap: wrap; gap: 1px 8px; font-family: Arial, Helvetica, sans-serif; font-size: 6.5px; font-style: normal; }

/* Facture */
.facture-table .designation { width: 49%; }
.facture-table .unit { width: 8%; }
.facture-table .qty { width: 9%; }
.facture-table .pu { width: 13%; }
.facture-table .tva { width: 8%; }
.facture-table .total-ht { width: 13%; }

/* Bon de livraison */
.bl-table .designation { width: 50%; }
.bl-table .qty { width: 10%; text-align: center; }
.bl-table .unit { width: 10%; text-align: center; }
.bl-table .pu { width: 14%; text-align: right; }
.bl-table .total-ht { width: 16%; text-align: right; }
.bl-table .empty-space td { height: 65mm; }
.bl-total { width: 45%; min-height: 9mm; margin-left: auto; padding: 2mm 3mm; display: flex; align-items: center; justify-content: space-between; border-left: 1px solid #64748b; border-right: 1px solid #64748b; border-bottom: 1px solid #64748b; font-size: 10px; font-weight: 800; }
.bl-notes { min-height: 16mm; margin-top: 4mm; padding: 2mm 3mm; border: 1px solid #94a3b8; font-size: 8px; }
.bl-notes > div { margin-top: 2mm; }
.bl-signatures { display: flex; justify-content: space-between; gap: 20mm; margin-top: 10mm; }
.bl-signature { width: 42%; min-height: 30mm; padding: 3mm; border: 1px solid #94a3b8; text-align: center; font-size: 10px; }
.signature-space { height: 21mm; }
.bl-katruck .quote-footer { margin-top: 4mm; }

.document-footer { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); text-align: center; font-size: 11px; }
.company-identity { display: flex; align-items: flex-start; gap: 18px; }
.doc-type { text-align: right; }
.summary { margin-top: 20px; text-align: right; }

/* =========================================================
   MODE HTML2PDF
   html2pdf utilise le CSS ecran, pas @media print.
   On retire donc la hauteur A4 exacte qui causait une page vide.
   ========================================================= */

body.pdf-generating { background: #fff !important; }

.document.pdf-export-mode {
    /* Capture au ratio A4 complet. 295mm laisse une petite securite a html2pdf
       pour eviter l'apparition d'une deuxieme page due aux arrondis pixels/mm. */
    width: 100% !important;
    max-width: 100% !important;
    height: 295mm !important;
    min-height: 295mm !important;
    max-height: 295mm !important;
    margin: 0 !important;
    padding: 7mm 8mm 5mm !important;
    overflow: hidden !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
}

.document.pdf-export-mode .quote-logo { height: 30mm !important; }
.document.pdf-export-mode .quote-logo img { max-width: 90mm !important; max-height: 25mm !important; }
.document.pdf-export-mode .quote-separator { margin-bottom: 5mm !important; }
.document.pdf-export-mode .quote-title { margin-bottom: 3mm !important; padding: 2mm 5mm !important; }
.document.pdf-export-mode .quote-title span { font-size: 14px !important; }
.document.pdf-export-mode .quote-meta { min-height: 17mm !important; }
.document.pdf-export-mode .client-row { min-height: 5mm !important; padding: .7mm 2mm !important; }
.document.pdf-export-mode .katruck-table { font-size: 12px !important; }
.document.pdf-export-mode .katruck-table thead th { height: 7mm !important; padding: 1mm !important; }
.document.pdf-export-mode .katruck-table tbody td { height: 6mm !important; padding: 1mm !important; }
.document.pdf-export-mode .katruck-table .empty-space td { height: 6mm !important; }
.document.pdf-export-mode.bl-katruck .katruck-table .empty-space td { height: 6mm !important; }
.document.pdf-export-mode .signature-area { top: 140mm !important; width: 44mm !important; height: 29mm !important; }
.document.pdf-export-mode .quote-bottom { min-height: 22mm !important; }
.document.pdf-export-mode .amount-words { min-height: 22mm !important; padding: 2mm !important; font-size: 10px !important; }
.document.pdf-export-mode .total-line { min-height: 4.4mm !important; font-size: 10px !important; }
.document.pdf-export-mode .total-line.final { font-size: 12px !important; }
.document.pdf-export-mode .quote-footer { margin-top: 1mm !important; padding-top: 1mm !important; font-size: 6.5px !important; }
.document.pdf-export-mode .footer-info { margin-top: 1mm !important; font-size: 6px !important; line-height: 1.2 !important; }
.document.pdf-export-mode.bl-katruck .bl-signatures { margin-top: 7mm !important; }
.document.pdf-export-mode.bl-katruck .bl-signature { min-height: 25mm !important; }
.document.pdf-export-mode.bl-katruck .signature-space { height: 16mm !important; }

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .dashboard-grid,
    .dashboard-grid.two-thirds,
    .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    aside {
        position: relative;
        width: 100%;
        height: auto;
        overflow: visible;
        padding: 14px 16px;
    }
    .with-sidebar { margin-left: 0; }
    main { padding: 18px 14px; }
    .brand { margin: 0; padding: 0 60px 0 0; border-bottom: 0; }
    .menu-toggle {
        display: inline-flex !important;
        position: absolute;
        top: 17px;
        right: 16px;
        width: 42px;
        min-height: 42px;
        padding: 0;
        background: rgba(255,255,255,.1);
        color: #fff;
        border-color: rgba(255,255,255,.12);
        z-index: 1002;
    }
    aside nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        max-height: 0;
        padding: 0 16px;
        overflow: hidden;
        opacity: 0;
        background: var(--nav);
        box-shadow: 0 16px 30px rgba(15,23,42,.25);
        transition: max-height .3s ease, opacity .2s ease, padding .3s ease;
    }
    aside nav.active { max-height: 720px; padding: 12px 16px 18px; opacity: 1; }
    .grid { grid-template-columns: 1fr; }
    .full { grid-column: auto; }
    .document-toolbar { max-width: 100% !important; }
}

@media (max-width: 760px) {
    .head { align-items: flex-start; flex-direction: column; }
    .document-toolbar { flex-direction: row; align-items: center; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .button,
    .toolbar-actions button { flex: 1; }
    .metric-grid { grid-template-columns: 1fr; }
    .dashboard-hero { align-items: flex-start; flex-direction: column; }
    .dashboard-hero h1 { font-size: 25px; }
    .section-title { align-items: flex-start; }
    .share-row,
    .actions { align-items: stretch; flex-direction: column; }
    .share-row > *,
    .actions > * { width: 100%; }
    .actions form button { width: 100%; }
    table:not(.katruck-table) { display: block; overflow-x: auto; white-space: nowrap; }
    .document { padding: 20px; overflow-x: auto; }
    .devis-katruck,
    .facture-katruck,
    .bl-katruck { min-width: 720px; }
}

@media (max-width: 520px) {
    .login { padding: 24px 20px; }
    .document-toolbar { flex-direction: column; align-items: stretch; }
    .btn-back { width: 100%; }
}

/* =========================================================
   IMPRESSION NAVIGATEUR
   Une seule definition d'impression pour tout le projet.
   ========================================================= */

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    html,
    body {
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    aside,
    .no-print,
    .head,
    .actions,
    .share-section,
    .document-footer,
    .app-footer,
    .menu-toggle {
        display: none !important;
    }

    .with-sidebar { margin: 0 !important; }
    main,
    main.with-sidebar { width: auto !important; margin: 0 !important; padding: 0 !important; }

    .document,
    .devis-katruck,
    .facture-katruck,
    .bl-katruck {
        width: 210mm !important;
        max-width: 210mm !important;
        height: 295mm !important;
        min-height: 295mm !important;
        max-height: 295mm !important;
        margin: 0 !important;
        padding: 7mm 8mm 5mm !important;
        overflow: hidden !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }

    .quote-logo { height: 30mm !important; }
    .quote-logo img { max-width: 90mm !important; max-height: 25mm !important; }
    .quote-separator { margin-bottom: 5mm !important; }
    .quote-title { margin-bottom: 3mm !important; padding: 2mm 5mm !important; }
    .quote-title span { font-size: 14px !important; }
    .quote-meta { min-height: 17mm !important; }
    .quote-client { font-size: 10px !important; }
    .client-row { min-height: 5mm !important; padding: .7mm 2mm !important; }

    .katruck-table { font-size: 12px !important; }
    .katruck-table thead th { height: 7mm !important; padding: 1mm !important; }
    .katruck-table tbody td { height: 6mm !important; padding: 1mm !important; }
    .katruck-table .empty-space td { height: 6mm !important; }
    .bl-katruck .katruck-table .empty-space td { height: 6mm !important; }

    .signature-area { top: 140mm !important; width: 44mm !important; height: 29mm !important; }
    .quote-bottom { min-height: 22mm !important; break-inside: avoid; page-break-inside: avoid; }
    .amount-words { min-height: 22mm !important; padding: 2mm !important; font-size: 10px !important; }
    .total-line { min-height: 4.4mm !important; font-size: 12px !important; }
    .total-line.final { font-size: 12px !important; }
    .quote-footer { margin-top: 1mm !important; padding-top: 1mm !important; font-size: 6.5px !important; break-inside: avoid; page-break-inside: avoid; }
    .footer-info { margin-top: 1mm !important; font-size: 6px !important; line-height: 1.2 !important; }

    .bl-table,
    .bl-total,
    .bl-notes,
    .bl-signatures { break-inside: avoid; page-break-inside: avoid; }
    .bl-signatures { margin-top: 7mm !important; }
    .bl-signature { min-height: 25mm !important; }
    .signature-space { height: 16mm !important; }
}

/* =========================================================
   MOBILE DASHBOARD V6
   Optimisation petits ecrans sans modifier les documents A4
   ========================================================= */

.dashboard-page {
    width: 100%;
    min-width: 0;
}

.dashboard-page > *,
.dashboard-grid > *,
.metric-grid > * {
    min-width: 0;
}

@media (max-width: 760px) {
    .dashboard-page {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .dashboard-page section {
        width: 100%;
        max-width: 100%;
        padding: 16px;
        margin-bottom: 14px;
        border-radius: 12px;
    }

    .dashboard-hero {
        width: 100%;
        max-width: 100%;
        padding: 20px 18px;
        margin-bottom: 14px;
        border-radius: 14px;
    }

    .dashboard-hero h1 {
        margin-bottom: 6px;
        font-size: 24px;
        line-height: 1.15;
    }

    .dashboard-hero p:not(.eyebrow) {
        font-size: 13px;
    }

    .hero-date {
        width: 100%;
        text-align: center;
        white-space: normal;
    }

    .metric-grid {
        width: 100%;
        gap: 10px;
        margin-bottom: 14px;
    }

    .metric-card {
        width: 100%;
        padding: 16px;
        border-radius: 12px;
    }

    .metric-card strong {
        margin: 5px 0;
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .dashboard-grid,
    .dashboard-grid.two-thirds {
        width: 100%;
        gap: 0;
    }

    .section-title {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .section-title > div {
        min-width: 0;
        flex: 1 1 180px;
    }

    .section-title h2 {
        font-size: 16px;
        line-height: 1.25;
    }

    .section-title a {
        flex: 0 0 auto;
        font-size: 11px;
    }

    .chart-panel {
        min-height: 250px;
        overflow: hidden;
    }

    .bars {
        width: 100%;
        height: 190px;
        gap: 8px;
        padding: 14px 2px 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .bar-item {
        flex: 1 0 42px;
        min-width: 42px;
    }

    .bar {
        width: 72%;
    }

    .bar-value {
        max-width: 58px;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 8.5px;
    }

    .bar-item b {
        font-size: 9px;
    }

    .compact-list > div {
        align-items: flex-start;
    }

    /* Les tableaux du dashboard deviennent des cartes lisibles. */
    .dashboard-table-wrap {
        overflow: visible;
        border-radius: 0;
    }

    table.dashboard-card-table {
        display: block;
        width: 100%;
        overflow: visible;
        white-space: normal;
        background: transparent;
    }

    .dashboard-card-table thead {
        display: none;
    }

    .dashboard-card-table tbody,
    .dashboard-card-table tr,
    .dashboard-card-table td {
        display: block;
        width: 100%;
    }

    .dashboard-card-table tr {
        margin-bottom: 10px;
        padding: 10px 12px;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        background: #fff;
        box-shadow: 0 3px 12px rgba(15,23,42,.04);
    }

    .dashboard-card-table tr:last-child {
        margin-bottom: 0;
    }

    .dashboard-card-table td {
        min-height: 34px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 7px 0;
        border: 0;
        border-bottom: 1px solid #eef2f7;
        text-align: right;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .dashboard-card-table td:last-child {
        border-bottom: 0;
    }

    .dashboard-card-table td::before {
        content: attr(data-label);
        flex: 0 0 82px;
        color: #64748b;
        font-size: 10px;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: .25px;
    }

    .dashboard-card-table td > * {
        min-width: 0;
    }

    .dashboard-card-table td a {
        overflow-wrap: anywhere;
    }

    .dashboard-card-table .badge {
        max-width: 100%;
        white-space: normal;
        text-align: center;
    }
}

@media (max-width: 420px) {
    main {
        padding: 12px 10px;
    }

    aside {
        padding-left: 12px;
        padding-right: 12px;
    }

    .brand {
        padding-right: 54px;
    }

    .brand img {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .brand h3 {
        font-size: 14px;
    }

    .menu-toggle {
        top: 13px;
        right: 12px;
        width: 40px;
        min-height: 40px;
    }

    .dashboard-page section {
        padding: 14px;
    }

    .dashboard-hero {
        padding: 18px 15px;
    }

    .metric-card {
        padding: 14px;
    }

    .dashboard-card-table td::before {
        flex-basis: 70px;
    }
}

/* =========================================================
   V7 - PARTAGE RESPONSIVE + REMISES
   ========================================================= */

/* Formulaires devis/facture */
.document-lines-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
}
.document-lines-table {
    min-width: 940px;
    margin: 0;
    box-shadow: none;
    border: 0;
}
.document-lines-table th,
.document-lines-table td { vertical-align: middle; }
.document-lines-table input,
.document-lines-table select { min-width: 90px; }
.document-lines-table .desc { min-width: 210px; }
.document-lines-table .qty { min-width: 75px; }
.document-lines-table .discount { min-width: 80px; }

.estimate-box {
    width: min(430px, 100%);
    margin: 18px 0 18px auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.estimate-box > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 42px;
    padding: 8px 14px;
    border-bottom: 1px solid #eef2f7;
}
.estimate-box > div:last-child { border-bottom: 0; }
.estimate-box span { color: var(--muted); font-size: 13px; }
.estimate-box strong { white-space: nowrap; }
.estimate-box .estimate-final { background: #f8fafc; }
.estimate-box .estimate-final span,
.estimate-box .estimate-final strong { color: #0f172a; font-weight: 800; }

/* Colonnes A4 avec remise */
.katruck-table .designation { width: 42% !important; }
.katruck-table .unit { width: 8% !important; }
.katruck-table .qty { width: 8% !important; }
.katruck-table .pu { width: 12% !important; }
.katruck-table .tva { width: 8% !important; }
.katruck-table .remise { width: 7% !important; }
.katruck-table .total-ht { width: 15% !important; }
.facture-table .designation { width: 42% !important; }
.facture-table .unit { width: 8% !important; }
.facture-table .qty { width: 8% !important; }
.facture-table .pu { width: 12% !important; }
.facture-table .tva { width: 8% !important; }
.facture-table .remise { width: 7% !important; }
.facture-table .total-ht { width: 15% !important; }

/* Bloc partage administration */
.share-card {
    width: 100%;
    max-width: 980px;
    margin: 22px auto;
    padding: 20px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(15,23,42,.06);
}
.share-card-header { margin-bottom: 16px; }
.share-card-header h3 { margin: 3px 0 4px; font-size: 18px; }
.share-card-header p { margin: 0; color: var(--muted); font-size: 13px; }
.share-eyebrow {
    display: block;
    color: #2563eb;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
}
.share-link-group > label {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}
.share-link-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
}
.share-link-input {
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #f8fafc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
}
.share-copy-button { min-width: 105px; }
.share-copy-status {
    display: block;
    min-height: 18px;
    padding-top: 5px;
    color: #15803d;
    font-size: 11px;
}
.share-copy-status.is-error { color: #b91c1c; }
.share-channel-grid {
    display: grid;
    grid-template-columns: minmax(190px, .7fr) minmax(0, 1.7fr);
    gap: 10px;
    margin-top: 12px;
}
.share-channel-button {
    width: 100%;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.share-email-form {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin: 0;
}
.share-email-form input[type="email"] { min-width: 0; margin: 0; }
.share-email-form button { white-space: nowrap; }

/* Lien public du devis */
.public-quote-page {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 16px;
}
.public-quote-card {
    width: 100%;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(15,23,42,.10);
}
.public-quote-header {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    padding: 26px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg,#ffffff,#f8fafc);
}
.public-company { min-width: 0; display: flex; align-items: flex-start; gap: 16px; }
.public-logo { flex: 0 0 auto; }
.public-logo .company-logo { width: auto; max-width: 150px; max-height: 82px; object-fit: contain; }
.public-company h1 { margin: 0 0 7px; font-size: 20px; }
.public-company p { margin: 0; color: #64748b; font-size: 12px; line-height: 1.5; }
.public-company-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin-top: 7px; color: #475569; font-size: 12px; }
.public-doc-badge {
    flex: 0 0 210px;
    padding: 15px 17px;
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
    text-align: right;
}
.public-doc-badge span,
.public-doc-badge small { display: block; color: #cbd5e1; }
.public-doc-badge span { margin-bottom: 5px; font-size: 10px; font-weight: 800; letter-spacing: 1px; }
.public-doc-badge strong { display: block; margin-bottom: 5px; font-size: 17px; }
.public-doc-badge small { font-size: 11px; }
.public-client-card {
    margin: 20px 26px;
    padding: 15px 17px;
    border: 1px solid #dbe3ec;
    border-radius: 12px;
    background: #f8fafc;
}
.public-client-card > span,
.public-notes > span { display: block; margin-bottom: 4px; color: #64748b; font-size: 9px; font-weight: 800; letter-spacing: .8px; }
.public-client-card strong { font-size: 16px; }
.public-client-card p { margin: 5px 0; color: #475569; font-size: 12px; }
.public-client-card small { color: #64748b; }
.public-quote-table-wrap { width: 100%; overflow-x: auto; padding: 0 26px; }
.public-quote-table { min-width: 720px; box-shadow: none; }
.public-quote-table th { padding: 11px 10px; background: #0f172a; color: #fff; font-size: 10px; }
.public-quote-table td { padding: 12px 10px; font-size: 12px; }
.public-quote-bottom {
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(270px,360px);
    gap: 24px;
    padding: 22px 26px 26px;
}
.public-notes { min-height: 100px; padding: 15px; border: 1px solid #e2e8f0; border-radius: 12px; }
.public-notes p { margin: 7px 0 0; color: #475569; font-size: 12px; }
.public-totals { overflow: hidden; border: 1px solid #dbe3ec; border-radius: 12px; }
.public-totals > div { min-height: 39px; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 8px 13px; border-bottom: 1px solid #eef2f7; font-size: 12px; }
.public-totals > div:last-child { border-bottom: 0; }
.public-totals span { color: #64748b; }
.public-totals strong { white-space: nowrap; }
.public-total-final { background: #0f172a; }
.public-total-final span,
.public-total-final strong { color: #fff !important; font-size: 13px; font-weight: 800; }
.public-quote-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 17px 26px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}
.public-quote-footer p { margin: 0; color: #64748b; font-size: 11px; }

@media (max-width: 760px) {
    .estimate-box { margin-left: 0; }

    .share-card { padding: 16px; margin: 16px auto; border-radius: 12px; }
    .share-link-control,
    .share-channel-grid,
    .share-email-form { grid-template-columns: 1fr; }
    .share-copy-button,
    .share-channel-button,
    .share-email-form button { width: 100%; }
    .share-link-input {
        min-height: 44px;
        font-size: 11px;
    }

    .public-quote-page { padding: 12px 10px; }
    .public-quote-card { border-radius: 13px; }
    .public-quote-header { flex-direction: column; padding: 18px 16px; gap: 16px; }
    .public-company { flex-direction: column; gap: 10px; }
    .public-logo .company-logo { max-width: 130px; max-height: 70px; }
    .public-doc-badge { flex-basis: auto; width: 100%; text-align: left; }
    .public-client-card { margin: 14px 16px; }
    .public-quote-table-wrap { padding: 0 16px; overflow: visible; }
    .public-quote-table { display: block !important; min-width: 0; width: 100%; white-space: normal !important; background: transparent; }
    .public-quote-table thead { display: none; }
    .public-quote-table tbody,
    .public-quote-table tr,
    .public-quote-table td { display: block; width: 100%; }
    .public-quote-table tr {
        margin-bottom: 10px;
        padding: 9px 12px;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        background: #fff;
    }
    .public-quote-table td {
        min-height: 34px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 7px 0;
        border: 0;
        border-bottom: 1px solid #eef2f7;
        text-align: right;
        white-space: normal;
    }
    .public-quote-table td:last-child { border-bottom: 0; }
    .public-quote-table td::before {
        content: attr(data-label);
        flex: 0 0 90px;
        color: #64748b;
        font-size: 10px;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
    }
    .public-quote-bottom { grid-template-columns: 1fr; gap: 12px; padding: 12px 16px 18px; }
    .public-quote-footer { flex-direction: column; align-items: stretch; padding: 15px 16px; }
    .public-quote-footer button { width: 100%; }
}

@media print {
    .public-quote-page { max-width: none !important; margin: 0 !important; padding: 0 !important; }
    .public-quote-card { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
    .public-quote-header { padding: 10mm 10mm 5mm !important; }
    .public-client-card { margin: 4mm 10mm !important; }
    .public-quote-table-wrap { padding: 0 10mm !important; overflow: visible !important; }
    .public-quote-table { display: table !important; min-width: 0 !important; width: 100% !important; }
    .public-quote-table thead { display: table-header-group !important; }
    .public-quote-table tbody { display: table-row-group !important; }
    .public-quote-table tr { display: table-row !important; margin: 0 !important; padding: 0 !important; border: 0 !important; }
    .public-quote-table th,
    .public-quote-table td { display: table-cell !important; width: auto !important; }
    .public-quote-table td::before { display: none !important; }
    .public-quote-bottom { padding: 5mm 10mm !important; }
    .public-quote-footer { padding: 3mm 10mm !important; }
}


/* =========================================================
   CREATION RAPIDE CLIENT - DEVIS / BL / FACTURE
   ========================================================= */
.customer-field-group {
    min-width: 0;
}
.customer-field-group > label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
}
.customer-select-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
}
.customer-select-row select {
    min-width: 0;
    width: 100%;
    margin-top: 0;
}
.customer-add-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    white-space: nowrap;
}
.customer-select-success {
    outline: 3px solid rgba(34,197,94,.20) !important;
    border-color: #22c55e !important;
    transition: outline .2s ease, border-color .2s ease;
}

body.modal-open {
    overflow: hidden;
}
.customer-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.customer-modal.is-open {
    display: flex;
}
.customer-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,.62);
    backdrop-filter: blur(3px);
}
.customer-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(720px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 30px 80px rgba(15,23,42,.28);
    animation: customerModalIn .18s ease-out;
}
@keyframes customerModalIn {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.customer-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 24px 17px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg,#fff,#f8fafc);
}
.customer-modal-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: #2563eb;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.2px;
}
.customer-modal-header h2 {
    margin: 0;
    color: #0f172a;
    font-size: 20px;
}
.customer-modal-header p {
    margin: 5px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}
.customer-modal-close {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    background: #eef2f7;
    color: #334155;
    font-size: 24px;
    line-height: 1;
}
.customer-modal-close:hover {
    background: #e2e8f0;
}
.customer-modal-form {
    padding: 20px 24px 24px;
}
.customer-modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 13px 16px;
}
.customer-modal-grid label {
    margin: 0;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}
.customer-modal-grid input,
.customer-modal-grid textarea {
    margin-top: 6px;
}
.customer-modal-grid textarea {
    min-height: 74px;
    resize: vertical;
}
.customer-modal-full {
    grid-column: 1 / -1;
}
.customer-required::after {
    content: ' *';
    color: #dc2626;
}
.customer-quick-error {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #fecaca;
    border-radius: 9px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
}
.customer-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #eef2f7;
}
.customer-modal-actions button {
    min-height: 41px;
}

@media (max-width: 760px) {
    .full-on-mobile {
        grid-column: 1 / -1;
    }
    .customer-select-row {
        grid-template-columns: 1fr;
    }
    .customer-add-button {
        width: 100%;
    }
    .customer-modal {
        align-items: flex-end;
        padding: 0;
    }
    .customer-modal-dialog {
        width: 100%;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
    }
    .customer-modal-header {
        padding: 18px 16px 14px;
    }
    .customer-modal-header h2 {
        font-size: 18px;
    }
    .customer-modal-form {
        padding: 16px;
    }
    .customer-modal-grid {
        grid-template-columns: 1fr;
        gap: 11px;
    }
    .customer-modal-full {
        grid-column: auto;
    }
    .customer-modal-actions {
        flex-direction: column-reverse;
    }
    .customer-modal-actions button {
        width: 100%;
    }
}

@media print {
    .customer-modal,
    .customer-add-button {
        display: none !important;
    }
}

/* =========================================================
   V10 - REFERENCES + GRILLE DOCUMENT CONTINUE
   ========================================================= */

/* Formulaires : nouvelle colonne reference */
.document-lines-table {
    min-width: 1060px;
}
.document-lines-table .product-reference,
#bl-items-table .product-reference {
    min-width: 105px;
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
}

/* Devis / Facture : 8 colonnes sur 100% */
.katruck-table .reference,
.facture-table .reference {
    width: 11% !important;
    text-align: left;
    overflow-wrap: anywhere;
}
.katruck-table .designation,
.facture-table .designation { width: 31% !important; }
.katruck-table .unit,
.facture-table .unit { width: 7% !important; }
.katruck-table .qty,
.facture-table .qty { width: 7% !important; }
.katruck-table .pu,
.facture-table .pu { width: 12% !important; }
.katruck-table .tva,
.facture-table .tva { width: 8% !important; }
.katruck-table .remise,
.facture-table .remise { width: 8% !important; }
.katruck-table .total-ht,
.facture-table .total-ht { width: 16% !important; }

/* BL : 6 colonnes sur 100% */
.bl-table .reference { width: 12% !important; text-align: left; overflow-wrap: anywhere; }
.bl-table .designation { width: 38% !important; }
.bl-table .qty { width: 10% !important; }
.bl-table .unit { width: 10% !important; }
.bl-table .pu { width: 14% !important; }
.bl-table .total-ht { width: 16% !important; }

/* Chaque cellule de la grande zone vide reste separee :
   les traits verticaux descendent jusqu'au bloc des totaux. */
.katruck-table .empty-space td {
    padding: 0 !important;
    border-left: 1px solid #64748b !important;
    border-right: 1px solid #64748b !important;
    border-top: 0 !important;
    border-bottom: 1px solid #64748b !important;
    background: #fff !important;
}

.amount-words .words {
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.public-amount-words {
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1.5;
}

@media (max-width: 760px) {
    .document-lines-table { min-width: 1080px; }
    #bl-items-table { min-width: 980px; }
}

/* =========================================================
   V11 - DEVIS PUBLIC PARTAGE / WHATSAPP
   Même présentation A4 que le devis interne.
   Sur mobile, l'A4 est réduit proportionnellement pour tenir
   dans la largeur de l'écran sans casser le tableau.
   ========================================================= */
.public-a4-share-page {
    width: 100%;
    padding: 22px 14px 30px;
    background: #eef2f7;
}

.public-a4-toolbar {
    width: min(210mm, 100%);
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 7px 24px rgba(15,23,42,.07);
}
.public-a4-toolbar > div {
    min-width: 0;
}
.public-a4-toolbar strong,
.public-a4-toolbar small {
    display: block;
}
.public-a4-toolbar strong {
    color: #0f172a;
    font-size: 14px;
}
.public-a4-toolbar small {
    margin-top: 2px;
    color: #64748b;
    font-size: 11px;
}
.public-a4-toolbar button {
    flex: 0 0 auto;
}

.public-a4-viewport {
    width: min(210mm, 100%);
    margin: 0 auto;
    overflow: visible;
}

.public-a4-viewport .public-shared-devis {
    width: 210mm;
    max-width: 210mm;
    min-width: 210mm;
    margin: 0;
}

@media (max-width: 760px) {
    .public-a4-share-page {
        padding: 10px 8px 20px;
        overflow-x: hidden;
    }

    .public-a4-toolbar {
        width: 100%;
        margin-bottom: 8px;
        padding: 10px;
        border-radius: 9px;
    }

    .public-a4-toolbar button {
        padding: 9px 10px;
        font-size: 11px;
    }

    .public-a4-viewport {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    /* Annule la règle mobile globale min-width:720px uniquement
       pour le document public : le JS le redimensionne ensuite. */
    .public-a4-viewport .public-shared-devis {
        width: 210mm !important;
        max-width: 210mm !important;
        min-width: 210mm !important;
        padding: 10mm 8mm 7mm !important;
        overflow: hidden !important;
    }
    .customer-solde {
        display: block !important;
    }
}

@media print {
    .public-a4-share-page {
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .public-a4-viewport {
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        overflow: visible !important;
    }

    .public-a4-viewport .public-shared-devis {
        transform: none !important;
        transform-origin: initial !important;
    }
}
