:root {
    --bleu: #1f6feb;
    --bleu-fonce: #16325c;
    --fond: #f4f6fb;
    --carte: #ffffff;
    --texte: #1d2433;
    --texte-doux: #5a6678;
    --bordure: #e3e8f0;
    --vert: #1a9e5c;
    --jaune: #e0a800;
    --rouge: #d64545;
    --gris: #7a8699;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--fond);
    color: var(--texte);
    font-size: 15px;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--bleu-fonce);
    color: #fff;
    padding: 14px 0;
    margin-bottom: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.logo { color: #fff; font-weight: 700; font-size: 18px; text-decoration: none; }
.topbar nav { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar nav a {
    color: #cdd9f0; text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 600;
}
.topbar nav a:hover, .topbar nav a.actif { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- Cartes / grilles ---------- */
.carte {
    background: var(--carte);
    border: 1px solid var(--bordure);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(20,30,60,.05);
}
.carte h2 { margin: 0 0 14px; font-size: 16px; }

.grille-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat {
    background: var(--carte);
    border: 1px solid var(--bordure);
    border-radius: 12px;
    padding: 16px;
}
.stat .valeur { font-size: 28px; font-weight: 800; }
.stat .label { color: var(--texte-doux); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat.attention { border-left: 4px solid var(--jaune); }
.stat.alerte { border-left: 4px solid var(--rouge); }

/* ---------- Tableaux ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--bordure); font-size: 14px; }
th { color: var(--texte-doux); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: #f8fafd; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge-bleu  { background: #e3edff; color: var(--bleu); }
.badge-jaune { background: #fff3cd; color: #8a6d00; }
.badge-vert  { background: #dcf5e8; color: var(--vert); }
.badge-gris  { background: #eef1f6; color: var(--gris); }
.badge-rouge { background: #fde3e3; color: var(--rouge); }
.badge-violet { background: #ece4fd; color: #6d28d9; }

/* ---------- Code barres Code 39 ---------- */
.b39 { display:flex; justify-content:center; flex-wrap:nowrap; overflow:hidden; }
.b39-barre { display:inline-block; width:2px; background:#000; height:40px; }
.b39-espace { display:inline-block; width:2px; background:#fff; }
.b39-fin { width:2px; background:transparent; }

/* ---------- Topbar utilisateur ---------- */
.topbar-user { display:flex; align-items:center; gap:10px; font-size:13px; }
.topbar-user a { color:#ffd7d7; text-decoration:none; font-weight:600; }
.topbar-user a:hover { text-decoration:underline; }

/* ---------- Checklist scan ---------- */
.coche { width:18px; height:18px; accent-color: var(--bleu); cursor:pointer; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-block;
    background: var(--bleu);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    margin-right: 6px;
    margin-bottom: 6px;
}
.btn:hover { background: #185dc9; }
.btn.secondaire { background: #eef1f6; color: var(--texte); }
.btn.secondaire:hover { background: #e2e7f0; }
.btn.danger { background: var(--rouge); }
.btn.succes { background: var(--vert); }
.btn.petit { padding: 5px 10px; font-size: 13px; }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--bordure);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: var(--texte);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--bleu); border-color: var(--bleu); }
.champ-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

/* ---------- File de préparation ---------- */
.filetage { display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; }
.etape {
    flex: 1 1 220px;
    background: #f8fafd;
    border: 1px solid var(--bordure);
    border-radius: 10px;
    padding: 12px;
    position: relative;
    font-size: 14px;
}
.etape .num {
    position: absolute; top: -10px; left: 12px;
    background: var(--bleu); color: #fff;
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12px;
}
.etape.etape-colis { border-color: var(--bleu); background: #eef4ff; }
.etape .titre { font-weight: 700; margin-bottom: 4px; }
.etape .detail { color: var(--texte-doux); font-size: 13px; }

.avis-colis {
    display: flex; align-items: center; gap: 12px;
    border: 2px solid var(--bleu);
    background: #eef4ff;
    border-radius: 10px;
    padding: 10px 14px;
    margin: 12px 0;
    font-weight: 700;
}
.avis-colis .taille { font-size: 22px; }

.alerte-stock {
    background: #fdecec;
    border: 1px solid #f5b8b8;
    color: #a03a3a;
    border-radius: 8px;
    padding: 8px 12px;
    margin: 6px 0;
    font-size: 13px;
    font-weight: 600;
}

/* ---------- Recherche ---------- */
.recherche {
    display: flex; gap: 8px; margin-bottom: 16px;
}
.recherche input { flex: 1; }

/* ---------- Flash messages ---------- */
.flash {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}
.flash.ok { background: #dcf5e8; color: var(--vert); }
.flash.err { background: #fde3e3; color: var(--rouge); }

/* ---------- Étiquette d'expédition A6 148x105 ---------- */
.etiquette-a6 {
    width: 740px;
    height: 525px;
    background: #fff;
    border: 2px solid #000;
    padding: 14px 18px;
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    flex-direction: column;
}
.a6-stripe { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; }
.a6-service { display: flex; align-items: center; gap: 10px; }
.a6-service-texte {
    font-weight: 800; font-size: 14px; letter-spacing: 1px;
    border: 2px solid #000; padding: 4px 10px;
}
.a6-titre {
    font-size: 12px; font-weight: 700; letter-spacing: 2px; color: #333;
    border: 1px solid #333; padding: 3px 10px;
}
.a6-trait { height: 4px; background: #000; flex: 1; }
.a6-barcode-zone {
    display: flex; justify-content: space-between; align-items: center;
    border: 1px solid #000; padding: 8px 14px; margin-bottom: 10px;
}
.b39-label .b39-barre { width: 3px; height: 60px; }
.b39-label .b39-espace { width: 3px; }
.b39-label .b39-fin { width: 6px; }
.a6-barcode-texte {
    font-family: "Courier New", monospace; font-size: 18px; font-weight: 700;
    letter-spacing: 5px; margin-top: 4px;
}
.a6-poids { text-align: right; padding-left: 16px; border-left: 1px solid #999; }
.a6-poids-valeur { font-size: 22px; font-weight: 900; }
.a6-adresses {
    display: flex; gap: 40px; flex: 1; align-items: stretch;
    border: 1px solid #000; padding: 10px 14px; margin-bottom: 10px;
}
.a6-de { flex: 1; font-size: 12px; line-height: 1.4; border-right: 1px dashed #999; padding-right: 18px; }
.a6-entete {
    font-size: 10px; font-weight: 800; letter-spacing: 2px; color: #111;
    border-bottom: 2px solid #000; padding-bottom: 2px; margin-bottom: 8px;
    text-transform: uppercase;
}
.a6-de-lignes { color: #333; white-space: nowrap; }
.a6-a { flex: 1.4; font-size: 16px; line-height: 1.35; text-transform: uppercase; }
.a6-a-lignes { font-weight: 700; font-size: 19px; }
.a6-pied {
    display: flex; justify-content: space-between; gap: 12px;
    font-size: 10px; color: #333; border-top: 1px solid #999; padding-top: 6px;
    flex-wrap: wrap;
}

@media print {
    @page {
        size: 148mm 105mm;
        margin: 0;
    }
    .no-print, .topbar, .footer { display: none !important; }
    body { background: #fff; }
    main.container { max-width: none; padding: 0; }
    .etiquette-a6 {
        width: 148mm; height: 105mm;
        border: none; padding: 4mm;
        box-sizing: border-box; transform-origin: top left;
    }
    .a6-barcode-texte { font-size: 14px; }
    .a6-a-lignes { font-size: 15px; }
    .a6-service-texte { font-size: 12px; }
    .a6-de { font-size: 10px; }
    .a6-pied { font-size: 8px; }
}

/* ---------- Sélecteur hôte / impression archive ---------- */
.etiquette-zone { border: 2px dashed var(--bordure); border-radius: 12px; padding: 20px 14px; text-align: center; }
.cadre-etiquette {
    display: inline-block;
    border: 2px solid #000;
    padding: 14px 22px;
    width: 320px;
    text-align: left;
    background: #fff;
    font-size: 13px;
    line-height: 1.35;
}
.cadre-etiquette .grand { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.cadre-etiquette .petit { font-size: 11px; color: #333; margin: 2px 0; }
.code-barres {
    font-family: "Courier New", monospace;
    font-size: 24px;
    letter-spacing: 3px;
    background: #fff;
    color: #000;
    border-top: 3px solid #000;
    border-bottom: 3px solid #000;
    padding: 4px 0;
    margin: 8px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
}

@media print {
    .no-print, .topbar, .footer { display: none !important; }
    body { background: #fff; }
    .carte { border: none; box-shadow: none; }
}

/* ---------- Pied de page ---------- */
.footer { text-align: center; color: var(--texte-doux); font-size: 13px; padding: 24px 0 30px; }