/* Logistique — orders table + livreurs admin. Standalone styles. */
:root {
    --lg-red:    #dc2626;
    --lg-red2:   #b91c1c;
    --lg-blue:   #2563eb;
    --lg-purple: #7c3aed;
    --lg-amber:  #d97706;
    --lg-green:  #16a34a;
    --lg-bg:     #f7f7f8;
    --lg-card:   #ffffff;
    --lg-border: #e5e7eb;
    --lg-muted:  #6b7280;
    --lg-text:   #1f2937;
    --lg-faint:  #f3f4f6;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body.lg-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--lg-bg); color: var(--lg-text);
    min-height: 100vh;
}
a { color: var(--lg-red); text-decoration: none; }

/* Top bar */
.lg-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; padding: 0 22px; height: 56px;
    border-bottom: 1px solid var(--lg-border);
    gap: 14px;
}
.lg-brand { font-size: 1.2rem; font-weight: 800; letter-spacing: 4px; color: var(--lg-text); display: inline-flex; align-items: center; gap: 10px; }
.lg-brand::before { content: ""; width: 9px; height: 9px; border-radius: 999px; background: var(--lg-red); }
.lg-brand small { color: var(--lg-muted); font-weight: 500; letter-spacing: 1.5px; font-size: .8rem; }
.lg-tb-right { display: flex; gap: 16px; align-items: center; font-size: .85rem; color: var(--lg-muted); }

.lg-tabs { display: flex; gap: 4px; }
.lg-tab {
    background: transparent; border: none;
    padding: 8px 18px; border-radius: 8px;
    font-size: 14px; font-weight: 700; color: var(--lg-muted);
    cursor: pointer; font-family: inherit;
    transition: all .12s ease;
}
.lg-tab:hover { background: var(--lg-faint); color: var(--lg-text); }
.lg-tab.is-active { background: var(--lg-red); color: #fff; }

.lg-pane { display: none; }
.lg-pane.is-active { display: block; }

/* Filters */
.lg-filters {
    background: #fff; border-bottom: 1px solid var(--lg-border);
    padding: 12px 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.lg-filters select, .lg-search {
    padding: 9px 14px; border: 1px solid var(--lg-border);
    border-radius: 8px; font-size: 14px; min-width: 180px;
    background: #fff; outline: none; font-family: inherit;
    transition: border-color .12s;
}
.lg-search { min-width: 220px; flex: 1; max-width: 360px; }
.lg-filters select:focus, .lg-search:focus { border-color: var(--lg-red); }

.lg-toggle { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--lg-muted); cursor: pointer; }
.lg-toggle input { accent-color: var(--lg-red); }

/* Buttons */
.lg-btn {
    padding: 8px 14px; border-radius: 8px;
    font-size: 13px; font-weight: 700; cursor: pointer;
    border: none; font-family: inherit;
    transition: background-color .12s, opacity .12s;
}
.lg-btn-primary   { background: var(--lg-red);   color: #fff; }
.lg-btn-primary:hover { background: var(--lg-red2); }
.lg-btn-secondary { background: var(--lg-faint); color: var(--lg-text); }
.lg-btn-secondary:hover { background: #e5e7eb; }
.lg-btn-success   { background: var(--lg-green); color: #fff; }
.lg-btn-success:hover { opacity: .9; }
.lg-btn:disabled  { opacity: .4; cursor: not-allowed; }
.lg-btn-sm { padding: 6px 10px; font-size: 12px; }
.lg-btn-icon {
    width: 30px; height: 30px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; background: var(--lg-faint); color: var(--lg-text);
    border: none; cursor: pointer; font-size: 14px;
    transition: background .12s;
}
.lg-btn-icon:hover { background: #e5e7eb; }

/* Table wrapper */
.lg-table-wrap { padding: 18px; }
.lg-loader { padding: 60px; text-align: center; color: var(--lg-muted); }

.lg-date-block {
    margin-bottom: 24px;
    background: #fff; border: 1px solid var(--lg-border);
    border-radius: 10px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.lg-date-header {
    padding: 12px 16px; background: #1f2937; color: #fff;
    font-size: 14px; font-weight: 700;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.lg-date-header .lg-date-label { font-weight: 800; }
.lg-date-header .count { background: rgba(255,255,255,.15); padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.lg-date-header.is-today { background: var(--lg-red); }
.lg-date-header.is-today .count { background: rgba(255,255,255,.22); }
.lg-today-tag {
    background: #fff; color: var(--lg-red);
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-style: normal; font-weight: 800;
    margin-left: 8px; letter-spacing: .5px;
}

.lg-trans-summary { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.lg-depart-summary {
    background: rgba(255,255,255,.14);
    padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    display: inline-flex; gap: 6px; align-items: center;
}
.lg-depart-summary strong { font-weight: 800; }
.lg-depart-summary .lg-pill-missing {
    background: #fde047; color: #713f12;
    font-style: normal; font-weight: 700;
    padding: 1px 6px; border-radius: 999px;
    font-size: 10px;
}
/* Récapitulatif transport — bouton + popup */
.lg-recap-btn {
    margin-left: auto; background: rgba(255,255,255,.16); color: #fff;
    border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
    font-size: 12px; font-weight: 700; padding: 6px 12px; cursor: pointer;
}
.lg-recap-btn:hover { background: rgba(255,255,255,.3); }
.lg-recap-bd {
    position: fixed; inset: 0; z-index: 400; display: none;
    background: rgba(15,23,42,.6); padding: 20px;
    align-items: center; justify-content: center;
}
.lg-recap-bd.open { display: flex; }
.lg-recap-box {
    background: #fff; border-radius: 14px; width: 100%; max-width: 1000px;
    max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.lg-recap-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--lg-border); position: sticky; top: 0; background: #fff; }
.lg-recap-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.lg-recap-x { border: none; background: var(--lg-faint); border-radius: 8px; width: 30px; height: 30px; font-size: 15px; cursor: pointer; }
.lg-recap-cards { padding: 16px 20px; display: flex; flex-direction: column; gap: 18px; }
.lg-recap-card-h { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--lg-muted); margin-bottom: 8px; }
.lg-recap-scroll { overflow-x: auto; }
.lg-recap-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.lg-recap-t th { background: var(--lg-faint); text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 800; color: var(--lg-muted); border-bottom: 1px solid var(--lg-border); white-space: nowrap; }
.lg-recap-t td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; }
.lg-recap-t .num { text-align: right; font-variant-numeric: tabular-nums; }
.lg-recap-miss { color: #b91c1c; font-weight: 800; }
.lg-recap-grp { color: #15803d; background: #f0fdf4; }
.lg-recap-matrix th, .lg-recap-matrix td { border-left: 1px solid #f1f5f9; }
.lg-recap-foot td { border-top: 2px solid #cbd5e1; background: #f8fafc; font-weight: 700; }
.lg-recap-sum { text-align: center; padding: 6px !important; }
.lg-recap-sum span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; padding: 4px 10px;
    background: #1f2937; color: #fff; border-radius: 8px;
    font-size: 15px; font-weight: 800;
}

/* Global summary banner above the date blocks */
.lg-global-summary {
    margin-bottom: 16px;
    background: #fff;
    border: 1px solid var(--lg-border);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.lg-global-total {
    font-weight: 800; font-size: 14px; color: var(--lg-text);
    background: var(--lg-faint); padding: 4px 12px; border-radius: 8px;
}

.lg-rot-header {
    padding: 8px 16px; background: var(--lg-faint);
    font-size: 12px; font-weight: 700; color: var(--lg-muted);
    text-transform: uppercase; letter-spacing: .5px;
    display: flex; gap: 10px; align-items: center;
    border-top: 1px solid var(--lg-border);
}
.lg-rot-dot { width: 9px; height: 9px; border-radius: 50%; }
.lg-rot-dot.r1 { background: #f59e0b; }
.lg-rot-dot.r2 { background: #8b5cf6; }
.lg-rot-dot.r3 { background: #06b6d4; }
.lg-rot-dot.sp { background: #94a3b8; }

.lg-tbl-scroll { overflow-x: auto; }
.lg-table {
    width: 100%; border-collapse: collapse;
    font-size: 13px; table-layout: fixed;
}
.lg-table th, .lg-table td {
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid var(--lg-border);
    vertical-align: middle;
}
.lg-table td { line-height: 1.4; }
.lg-table th {
    background: #fafafa; font-weight: 700; font-size: 10px;
    text-transform: uppercase; letter-spacing: .5px; color: var(--lg-muted);
    white-space: nowrap;
}
.lg-table tbody tr:hover { background: #fafafb; }
.lg-table tbody tr.lg-group-sep td { border-top: 2px solid #cbd5e1; }
.lg-table .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.lg-table .lg-bcom { font-family: monospace; font-weight: 700; }
.lg-table .lg-grp-tag { color: #16a34a; font-weight: 700; font-size: 11px; }

/* Note icon next to b.commande */
.lg-note-ic {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; margin-left: 5px; padding: 0; vertical-align: middle;
    border: none; border-radius: 6px; background: #dbeafe; color: #2563eb;
    cursor: pointer; animation: lgNotePulse 1.4s ease-in-out infinite;
}
.lg-note-ic svg { width: 14px; height: 14px; }
.lg-note-ic:hover { background: #bfdbfe; }
@keyframes lgNotePulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(37,99,235,.45); }
    50%     { box-shadow: 0 0 0 5px rgba(37,99,235,0); }
}
.lg-note-bd {
    position: fixed; inset: 0; z-index: 500; background: rgba(15,23,42,.55);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.lg-note-box {
    background: #fff; border-radius: 14px; width: 100%; max-width: 420px;
    padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.lg-note-h { font-size: 14px; font-weight: 800; color: #1f2937; margin-bottom: 10px; }
.lg-note-txt { font-size: 14px; line-height: 1.6; color: #334155; white-space: pre-wrap; word-break: break-word; }
.lg-note-close {
    margin-top: 16px; width: 100%; border: none; border-radius: 10px;
    background: #2563eb; color: #fff; font-size: 14px; font-weight: 700;
    padding: 11px; cursor: pointer;
}
.lg-note-close:active { background: #1d4ed8; }

/* Two-line cell helpers */
.lg-cell-main { font-size: 12px; font-weight: 600; color: var(--lg-text); }
.lg-cell-sub  { font-size: 11px; color: var(--lg-muted); margin-top: 2px; }
/* Paiement cell with alert */
.lg-pmt-cell  { display: flex; align-items: center; gap: 5px; }
/* Délais mobilisation = 0 alert */
.lg-dm-alert {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    background: #dc2626; color: #fff;
    font-size: 22px; font-weight: 900; flex-shrink: 0;
    cursor: default;
    box-shadow: 0 0 0 4px rgba(220,38,38,.25);
    animation: dm-pulse 1.4s ease-in-out infinite;
}
@keyframes dm-pulse {
    0%,100% { box-shadow: 0 0 0 4px rgba(220,38,38,.25); }
    50%      { box-shadow: 0 0 0 8px rgba(220,38,38,.08); }
}

/* État badges (color-coded) */
.lg-state {
    display: inline-block;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.lg-state-valide      { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.lg-state-dispatcher  { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.lg-state-encour      { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.lg-state-pret        { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.lg-state-preparer    { background: #fce7f3; color: #9d174d; border-color: #fbcfe8; }
.lg-state-default     { background: var(--lg-faint); color: var(--lg-muted); border-color: var(--lg-border); }

/* Transport icon chips */
.lg-trans { display: inline-flex; align-items: center; gap: 6px; }
.lg-trans-icon { width: 22px; height: 22px; flex-shrink: 0; }
.lg-trans-plateau .lg-trans-icon { color: var(--lg-red); }
.lg-trans-solo    .lg-trans-icon { color: var(--lg-blue); }
.lg-trans-h100    .lg-trans-icon { color: var(--lg-purple); }
.lg-trans-person  .lg-trans-icon { color: var(--lg-amber); }
.lg-trans-default .lg-trans-icon { color: var(--lg-muted); }

/* Action menu — icon-only buttons */
.lg-actions { display: flex; gap: 3px; flex-wrap: wrap; white-space: normal; }
.lg-btn-act {
    border: 1px solid var(--lg-border);
    background: #fff;
    color: var(--lg-text);
    width: 28px; height: 28px; padding: 0;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background-color .12s, border-color .12s;
    flex-shrink: 0;
}
.lg-btn-act:hover { background: var(--lg-faint); border-color: #cbd5e1; }
.lg-btn-act svg { width: 14px; height: 14px; flex-shrink: 0; }
/* WhatsApp : vert, gris une fois envoyé (reste cliquable) */
.lg-btn-act.lg-wa { background: #16a34a; border-color: #16a34a; color: #fff; }
.lg-btn-act.lg-wa:hover { background: #15803d; border-color: #15803d; }
.lg-btn-act.lg-wa.sent { background: #94a3b8; border-color: #94a3b8; color: #fff; }
.lg-btn-act.lg-wa.sent:hover { background: #64748b; border-color: #64748b; }
/* Message client : vert, gris une fois envoyé (reste cliquable) */
.lg-btn-act.lg-cl { background: #16a34a; border-color: #16a34a; color: #fff; }
.lg-btn-act.lg-cl:hover { background: #15803d; border-color: #15803d; }
.lg-btn-act.lg-cl.sent { background: #94a3b8; border-color: #94a3b8; color: #fff; }
.lg-btn-act.lg-cl.sent:hover { background: #64748b; border-color: #64748b; }
.lg-btn-act-off {
    color: #d1d5db;
    background: #fafafa;
    cursor: not-allowed;
}
.lg-btn-act-off svg { color: #d1d5db; }
.lg-btn-act-off:hover { background: #fafafa; border-color: var(--lg-border); }

/* Type de livraison color-coded badges */
.lg-typeliv {
    display: inline-block;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .3px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.lg-typeliv-rendu       { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.lg-typeliv-depart      { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.lg-typeliv-ech-rendu   { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.lg-typeliv-ech-depart  { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.lg-typeliv-ech-a-app   { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.lg-typeliv-default     { background: var(--lg-faint); color: var(--lg-muted); border-color: var(--lg-border); }

/* Multi-select for "Cacher type de livraison" */
.lg-hide-group {
    display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 6px 10px; border: 1px solid var(--lg-border); border-radius: 8px;
    background: #fff; font-size: 12px;
}
.lg-hide-group .lg-hide-label {
    font-weight: 700; color: var(--lg-muted);
    text-transform: uppercase; letter-spacing: .4px; font-size: 10px;
}
.lg-hide-chip {
    display: inline-flex; align-items: center; gap: 5px;
    cursor: pointer; user-select: none;
    padding: 3px 8px; border-radius: 999px;
    background: var(--lg-faint); color: var(--lg-text);
    font-size: 11px; font-weight: 600;
    border: 1px solid transparent;
    transition: background-color .12s;
}
.lg-hide-chip:hover { background: #e5e7eb; }
.lg-hide-chip input { accent-color: var(--lg-red); }
.lg-hide-chip.is-on {
    background: #fee2e2; color: #991b1b; border-color: #fca5a5;
}

/* Modal */
.lg-modal-bd {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    padding: 16px;
}
.lg-modal-bd.open { display: flex; }
.lg-modal {
    background: #fff; width: 100%;
    max-width: 540px; border-radius: 12px;
    padding: 24px; max-height: 92vh; overflow-y: auto;
    position: relative;
}
.lg-modal h2 { font-size: 17px; font-weight: 800; margin-bottom: 6px; padding-right: 30px; }
.lg-modal .lg-sub { color: var(--lg-muted); font-size: 12px; margin-bottom: 14px; }
.lg-modal-x {
    position: absolute; top: 12px; right: 14px;
    background: none; border: none; font-size: 20px; color: var(--lg-muted);
    cursor: pointer;
}
.lg-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* Articles modal */
.lg-art-list { margin-bottom: 4px; }
.lg-art-row {
    display: flex; align-items: baseline; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--lg-border);
    font-size: 13px;
}
.lg-art-row:last-child { border-bottom: none; }
.lg-art-qty {
    font-family: monospace; font-weight: 800; font-size: 14px;
    color: var(--lg-red); min-width: 36px; flex-shrink: 0;
}
.lg-art-name { font-weight: 600; color: var(--lg-text); }
.lg-art-lignes {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-top: 12px; padding-top: 10px;
    border-top: 1px solid var(--lg-border);
}
.lg-art-ligne {
    background: var(--lg-faint); padding: 4px 10px;
    border-radius: 6px; font-size: 12px; color: var(--lg-muted);
}
.lg-art-ligne strong { color: var(--lg-text); }
.lg-art-total {
    margin-top: 12px; padding-top: 10px;
    border-top: 2px solid var(--lg-border);
    font-size: 13px; font-weight: 600;
}

.lg-field { margin-top: 10px; }
.lg-field label { display: block; font-size: 12px; font-weight: 700; color: var(--lg-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.lg-field input, .lg-field select, .lg-field textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--lg-border); border-radius: 8px;
    font-size: 14px; font-family: inherit;
    outline: none; background: #fff;
    transition: border-color .12s;
}
.lg-field textarea { min-height: 80px; resize: vertical; }
.lg-field input:focus, .lg-field select:focus, .lg-field textarea:focus { border-color: var(--lg-red); }

/* Livreurs tab */
.lg-livreurs-wrap {
    max-width: 1100px; margin: 18px auto;
    padding: 0 18px;
    display: grid; grid-template-columns: 360px 1fr; gap: 18px;
    align-items: start;
}
@media (max-width: 800px) { .lg-livreurs-wrap { grid-template-columns: 1fr; } }
.lg-card {
    background: #fff; border: 1px solid var(--lg-border);
    border-radius: 12px; padding: 18px;
    box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.lg-card h2 { font-size: 15px; font-weight: 800; margin-bottom: 12px; }
.lg-form-grid { display: grid; gap: 8px; }
.lg-form-actions { margin-top: 12px; }

.lg-liv-row {
    display: grid;
    grid-template-columns: 1fr 1fr 130px 110px 90px;
    gap: 8px; align-items: center;
    padding: 10px; border-bottom: 1px solid var(--lg-border);
    font-size: 13px;
}
.lg-liv-row:last-child { border-bottom: none; }
.lg-liv-row strong { font-weight: 700; }
.lg-liv-row code { font-family: monospace; font-size: 12px; color: var(--lg-muted); }
.lg-liv-empty { padding: 30px; text-align: center; color: var(--lg-muted); font-size: 13px; }
