/* =====================================================
   Tableau de bord — Commande Pro
===================================================== */
:root {
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --bg: #f5f7fb;
    --card: #ffffff;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-soft: #eaf1ff;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex-shrink: 0; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.menu { background: #0f172a; color: #cbd5e1; padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.marque { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.marque img, .pastille { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; }
.pastille { display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 800; }
.marque b { display: block; color: #fff; font-size: .95rem; line-height: 1.25; }
.marque small { color: #94a3b8; font-size: .75rem; }
.menu nav, .menu-bas { display: flex; flex-direction: column; gap: 4px; }
.menu-bas { margin-top: auto; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #cbd5e1; font-weight: 600; font-size: .93rem; }
.menu a svg { width: 19px; height: 19px; }
.menu a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.menu a.actif { background: var(--blue); color: #fff; }
.contenu { padding: 26px 30px 60px; min-width: 0; }
.titre-page { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.titre-page h1 { font-size: 1.55rem; letter-spacing: -.02em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-mobile { display: none; }

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; }
    .menu { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; }
    .menu nav { display: none; }
    .menu-bas { margin: 0 0 0 auto; flex-direction: row; }
    .menu-bas a span { display: none; }
    .contenu { padding: 18px 16px 96px; }
    .titre-page h1 { font-size: 1.3rem; }
    .nav-mobile {
        display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
        background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }
    .nav-mobile a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; font-weight: 600; color: var(--muted); padding: 4px; }
    .nav-mobile a svg { width: 22px; height: 22px; }
    .nav-mobile a.actif { color: var(--blue); }
    .nav-mobile a:hover { text-decoration: none; }
}

/* ---------- Bandeaux ---------- */
.bandeau { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.bandeau.succes { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.bandeau.erreur { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.bandeau.alerte { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.bandeau.info { background: var(--blue-soft); border-color: #bfdbfe; color: #1e3a8a; }

/* ---------- Cartes et boutons ---------- */
.carte { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.carte + .carte { margin-top: 16px; }
.carte h2 { font-size: 1.08rem; margin-bottom: 4px; }
.carte .aide { color: var(--muted); font-size: .9rem; margin-bottom: 16px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px;
    border: 1px solid transparent; background: var(--blue); color: #fff; font-weight: 700; font-size: .92rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn.secondaire { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn.secondaire:hover { background: var(--bg); }
.btn.danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.vert { background: var(--green); }
.btn.petit { padding: 6px 11px; font-size: .84rem; border-radius: 8px; }
.btn:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37, 99, 235, .35); outline-offset: 2px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: color-mix(in srgb, var(--b) 12%, #fff); color: var(--b); white-space: nowrap; }
.etiquette { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .75rem; font-weight: 700; background: #fef3c7; color: #92400e; }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat span { color: var(--muted); font-size: .84rem; font-weight: 600; }
.stat b { display: block; font-size: 1.6rem; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: .8rem; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Filtres ---------- */
.onglets { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: thin; }
.onglets a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: .88rem; white-space: nowrap; }
.onglets a:hover { text-decoration: none; border-color: var(--line-2); }
.onglets a.actif { background: var(--ink); border-color: var(--ink); color: #fff; }
.onglets a i { font-style: normal; font-size: .76rem; background: var(--bg); color: var(--muted); border-radius: 999px; padding: 0 7px; }
.onglets a.actif i { background: rgba(255, 255, 255, .18); color: #fff; }
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filtres input, .filtres select { height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; }
.filtres input[type="search"] { flex: 1; min-width: 200px; }

/* ---------- Liste des commandes ---------- */
.tableau { width: 100%; border-collapse: collapse; background: #fff; }
.tableau-carte { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tableau th { text-align: start; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 11px 14px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tableau td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau tr:hover td { background: #fafbff; }
.tableau .ref { font-weight: 800; color: var(--ink); }
.tableau .gris { color: var(--muted); font-size: .82rem; }
.tableau .montant { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tel { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tel svg { width: 15px; height: 15px; }
select.statut { height: 34px; padding: 0 8px; border-radius: 8px; border: 1.5px solid var(--b, var(--line-2)); color: var(--b, var(--ink)); font-weight: 700; background: color-mix(in srgb, var(--b, #fff) 8%, #fff); cursor: pointer; max-width: 160px; }
.vide { text-align: center; padding: 50px 20px; color: var(--muted); }
.vide b { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }

/* Sur téléphone, chaque commande devient une carte */
@media (max-width: 860px) {
    .tableau thead { display: none; }
    .tableau, .tableau tbody, .tableau tr, .tableau td { display: block; width: 100%; }
    .tableau-carte { background: transparent; border: 0; box-shadow: none; }
    .tableau tr { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 12px 14px; box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; }
    .tableau td { border: 0; padding: 0; }
    .tableau tr:hover td { background: transparent; }
    .tableau td.c-ref { grid-column: 1; }
    .tableau td.c-total { grid-column: 2; grid-row: 1; text-align: end; }
    .tableau td.c-client, .tableau td.c-lieu, .tableau td.c-produit { grid-column: 1 / -1; }
    .tableau td.c-statut { grid-column: 1; }
    .tableau td.c-voir { grid-column: 2; text-align: end; }
}

/* ---------- Formulaires ---------- */
.grille { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.grille .plein { grid-column: 1 / -1; }
@media (max-width: 700px) { .grille { grid-template-columns: 1fr; } }
.champ label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 5px; }
.champ label small { color: var(--muted); font-weight: 500; }
.champ input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), .champ select, .champ textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; min-height: 42px;
}
.champ textarea { min-height: 110px; resize: vertical; }
.champ input:focus, .champ select:focus, .champ textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.champ .note { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.case { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.case input { width: 18px; height: 18px; accent-color: var(--blue); }
.avec-prefixe { display: flex; align-items: stretch; }
.avec-prefixe span { display: flex; align-items: center; padding: 0 10px; background: var(--bg); border: 1px solid var(--line-2); border-inline-end: 0; border-radius: 10px 0 0 10px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.avec-prefixe input { border-radius: 0 10px 10px 0 !important; }
.barre-enregistrer { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 4px; display: flex; gap: 10px; justify-content: flex-end; }
@media (max-width: 860px) { .barre-enregistrer { bottom: 64px; } }

/* ---------- Images d'un produit ---------- */
.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.image { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.image img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.image .outils { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: .78rem; gap: 6px; }
.image .principale { position: absolute; top: 6px; inset-inline-start: 6px; background: var(--blue); color: #fff; font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.depot { border: 2px dashed var(--line-2); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); background: #fafbfc; }
.depot input { margin-top: 8px; }

/* ---------- Produits ---------- */
.produits { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.produit { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.produit .photo { aspect-ratio: 16 / 10; background: var(--bg); position: relative; }
.produit .photo img { width: 100%; height: 100%; object-fit: cover; }
.produit .photo .badge { position: absolute; top: 10px; inset-inline-start: 10px; }
.produit .corps { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.produit h3 { font-size: 1rem; line-height: 1.3; }
.produit .chiffres { display: flex; gap: 14px; color: var(--muted); font-size: .84rem; }
.produit .chiffres b { color: var(--ink); }
.produit .boutons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* ---------- Tarifs de livraison ---------- */
.tarifs { width: 100%; border-collapse: collapse; }
.tarifs th { text-align: start; font-size: .78rem; text-transform: uppercase; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.tarifs td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tarifs input { width: 100%; max-width: 140px; height: 38px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; }
.tarifs tr.off td:first-child { color: var(--muted); }

/* ---------- Détail d'une commande ---------- */
.deux-colonnes { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .deux-colonnes { grid-template-columns: 1fr; } }
.infos { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.infos dt { color: var(--muted); font-size: .88rem; }
.infos dd { font-weight: 600; }
.chrono { list-style: none; }
.chrono li { padding: 8px 0 8px 18px; border-inline-start: 2px solid var(--line); position: relative; font-size: .9rem; }
.chrono li::before { content: ""; position: absolute; inset-inline-start: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--b, var(--blue)); }
.chrono small { color: var(--muted); display: block; }

/* ---------- Connexion ---------- */
.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 400px at 50% -10%, #dbeafe, transparent), var(--bg); }
.boite-connexion { width: 100%; max-width: 400px; }
.boite-connexion h1 { font-size: 1.4rem; text-align: center; margin-bottom: 4px; }
.boite-connexion .sous { text-align: center; color: var(--muted); margin-bottom: 22px; }
.boite-connexion .champ { margin-bottom: 14px; }
.boite-connexion .btn { width: 100%; padding: 13px; font-size: 1rem; }
