/*
 * Navigation et en-tete MaGestion, pour trois tailles d'ecran :
 *   1024 px et plus  : colonne d'icones, sous-menu flottant au survol ;
 *   moins de 1024 px : barre du bas + menu plein ecran.
 */
#mg-nav, #mg-tabbar, #mg-sheet, .mg-brand { display: none; }

/* ===================== En-tete : une seule ligne, a toutes les largeurs ===================== */
html.mg-nav .theme-header-bg > div { padding: 10px 16px !important; }
html.mg-nav .theme-header-bg > div > div {
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 12px !important;
}
/* Groupe de gauche (marque, boutons) et groupe de droite (actions) */
html.mg-nav .theme-header-bg > div > div > div:first-child { flex: 0 1 auto; min-width: 0; }
html.mg-nav .theme-header-bg > div > div > div:last-child {
    flex-wrap: nowrap !important;
    justify-content: flex-end;
    margin-left: auto;
    flex: 0 0 auto;
    gap: 8px !important;
}
html.mg-nav .theme-header-bg > div > div > i.fa-info-circle { flex: 0 0 auto; margin: 0; }

html.mg-nav .mg-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--mg-ink) !important;
    text-decoration: none !important;
    white-space: nowrap;
}
.mg-brand-name { overflow: hidden; text-overflow: ellipsis; }

/* Etat de l'abonnement, au milieu de la barre du haut */
.mg-abo[hidden] { display: none !important; }
.mg-abo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 auto;
    min-width: 0;
    max-width: 46%;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid #DDF1E6;
    background: #F1FAF5;
    color: #1E6B47 !important;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none !important;
    white-space: nowrap;
}
a.mg-abo:hover, a.mg-abo:focus-visible { filter: brightness(.97); }
a.mg-abo:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: 2px; }
.mg-abo-txt { overflow: hidden; text-overflow: ellipsis; }
.mg-abo-dot { width: 8px; height: 8px; border-radius: 50%; background: #2FA36B; flex: 0 0 auto; }
.mg-abo-bientot, .mg-abo-attente { border-color: #FBE3C8; background: #FFF6EA; color: #9A5A0B !important; }
.mg-abo-bientot .mg-abo-dot, .mg-abo-attente .mg-abo-dot { background: #F08A24; }
.mg-abo-urgent, .mg-abo-expire, .mg-abo-aucun { border-color: #F6CFCF; background: #FDECEC; color: #B02A2A !important; font-weight: 600; }
.mg-abo-urgent .mg-abo-dot, .mg-abo-expire .mg-abo-dot, .mg-abo-aucun .mg-abo-dot { background: #D64545; }
html.mg-nav .theme-header-bg > div > div > .mg-abo + div { margin-left: 0; }
@media (max-width: 1023px) {
    /* Sur telephone, la barre est etroite : on n'affiche la pastille que s'il faut agir. */
    .mg-abo-ok { display: none !important; }
    /* Quand il faut agir, la pastille passe avant le nom de l'entreprise, qui se raccourcit. */
    .mg-abo { max-width: none; flex: 0 0 auto; margin: 0 auto 0 0; padding: 6px 10px; font-size: 12.5px; }
}
/* Texte complet sur grand ecran, texte court quand la place manque. */
.mg-abo-court { display: none; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1279px) {
    .mg-abo-txt { display: none; }
    .mg-abo-court { display: inline; }
}
.mg-brand-bars { width: 26px; height: 26px; flex: 0 0 auto; background: url(mg-symbole.png) center / contain no-repeat; }

/* Sous 1280 px : la date et le raccourci de reparation laissent la place. */
@media (max-width: 1279px) {
    html.mg-nav .theme-header-bg button.lg\:tw-inline-flex:not(.side-bar-collapse),
    html.mg-nav .theme-header-bg a[href*="sub_type=repair"] { display: none !important; }
}

/* ===================== Ordinateur : colonne d'icones + sous-menu ===================== */
@media (min-width: 1024px) {
    html.mg-nav aside.side-bar {
        width: auto !important;
        flex-direction: row !important;
        background: #fff;
        position: relative;
        z-index: 30;
    }
    /* Le menu d'origine (logo, recherche, liste) laisse la place au nouveau. */
    html.mg-nav aside.side-bar > :not(#mg-nav) { display: none !important; }
    html.mg-nav #mg-nav { display: flex; height: 100%; min-height: 0; }

    #mg-rail {
        width: 88px;
        flex: 0 0 88px;
        height: 100%;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
        padding: 12px 8px 16px;
        display: flex;
        flex-direction: column;
        gap: 2px;
        border-right: 1px solid var(--mg-line);
        background: #fff;
    }
    #mg-rail::-webkit-scrollbar { display: none; }

    .mg-rail-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding: 7px 2px;
        border: 0;
        border-radius: 12px;
        background: none;
        color: #3F4354 !important;
        font-family: inherit;
        font-size: 11px;
        font-weight: 500;
        line-height: 1.15;
        text-align: center;
        text-decoration: none !important;
        cursor: pointer;
        width: 100%;
    }
    .mg-rail-btn:hover .mg-rail-ico { background: var(--mg-orange-soft); border-color: var(--mg-orange); color: var(--mg-orange-dark); }
    .mg-rail-btn:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: 2px; }
    .mg-rail-btn[aria-current="true"] { color: var(--mg-orange-dark) !important; font-weight: 600; }
    .mg-rail-btn[aria-current="true"] .mg-rail-ico { background: var(--mg-orange); border-color: var(--mg-orange); color: #fff; }
    .mg-rail-label { overflow-wrap: anywhere; }

    .mg-rail-btn.mg-open .mg-rail-ico { background: var(--mg-orange-soft); border-color: var(--mg-orange); color: var(--mg-orange-dark); }
    .mg-rail-btn[aria-current="true"].mg-open .mg-rail-ico { background: var(--mg-orange); color: #fff; }

    /* Sous-menu : petite fenetre flottante a cote de l'icone survolee. */
    #mg-panel {
        display: none;
        position: fixed;
        left: 94px;
        top: 8px;
        z-index: 1045;
        width: 248px;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: #cdd5df transparent;
        padding: 12px 8px;
        border: 1px solid var(--mg-line);
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 12px 32px rgba(27, 29, 40, .14), 0 2px 6px rgba(27, 29, 40, .06);
    }
    html.mg-panel-open #mg-panel { display: block; animation: mg-panel-in .12s ease-out; }
    /* Pont invisible entre l'icone et la fenetre : la souris peut passer sans la refermer. */
    #mg-panel::before { content: ""; position: fixed; top: 0; bottom: 0; left: 80px; width: 16px; }

    /* La colonne d'icones ne se replie plus : les boutons d'origine sont inutiles. */
    html.mg-nav .small-view-button,
    html.mg-nav .theme-header-bg .side-bar-collapse { display: none !important; }
}

/* Icone d'une rubrique (colonne d'ordinateur et menu de telephone) */
.mg-rail-ico {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--mg-line);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #3F4354;
    flex: 0 0 auto;
    transition: background-color .15s, border-color .15s, color .15s;
}
.mg-rail-ico svg { width: 20px !important; height: 20px !important; color: inherit !important; }

/* Liens d'un sous-menu (ordinateur et telephone) */
.mg-panel-title { font-size: 13px; font-weight: 500; color: var(--mg-muted); padding: 2px 12px 10px; }
.mg-panel-head { font-size: 12px; font-weight: 600; color: var(--mg-ink); padding: 14px 12px 4px; }
#mg-panel a, .mg-sheet-links a {
    display: block;
    padding: 8px 12px;
    border-radius: 10px;
    color: #3F4354 !important;
    font-size: 14px;
    line-height: 1.3;
    text-decoration: none !important;
}
#mg-panel a:hover, .mg-sheet-links a:hover { background: #F7F8FA; color: var(--mg-ink) !important; }
#mg-panel a:focus-visible, .mg-sheet-links a:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: -2px; }
#mg-panel a.mg-on, .mg-sheet-links a.mg-on { background: var(--mg-orange-soft); color: var(--mg-orange-dark) !important; font-weight: 600; }

@keyframes mg-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mg-panel-in { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }

/* ===================== Telephone : barre du bas + menu plein ecran ===================== */
@media (max-width: 1023px) {
    /* Le menu d'origine et son bouton ne servent plus. */
    html.mg-nav aside.side-bar,
    html.mg-nav .small-view-button,
    html.mg-nav .overlay { display: none !important; }

    html.mg-nav #mg-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1040;
        background: #fff;
        border-top: 1px solid var(--mg-line);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    }
    .mg-tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: 54px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border: 0;
        background: none;
        border-radius: 12px;
        color: #5B6072 !important;
        font-family: inherit;
        font-size: 11px;
        font-weight: 500;
        text-decoration: none !important;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .mg-tab-ico { display: flex; width: 44px; height: 28px; align-items: center; justify-content: center; border-radius: 14px; }
    .mg-tab-ico svg { width: 22px; height: 22px; }
    .mg-tab[aria-current="page"] { color: var(--mg-orange-dark) !important; font-weight: 600; }
    .mg-tab[aria-current="page"] .mg-tab-ico { background: var(--mg-orange-soft); }
    .mg-tab:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: -2px; }
    .mg-tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

    /* La page laisse la place a la barre du bas. */
    html.mg-nav #scrollable-container { padding-bottom: 76px; }
    html.mg-nav .scrolltop { bottom: 84px !important; }

    html.mg-nav #mg-sheet:not([hidden]) {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: auto 0 0 0;
        max-height: 88vh;
        z-index: 1035;
        background: #fff;
        border-radius: 22px 22px 0 0;
        /* L'ombre large assombrit la page derriere le menu. */
        box-shadow: 0 0 0 100vmax rgba(27, 29, 40, .45);
        padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px));
        animation: mg-sheet-in .18s ease-out;
    }
    .mg-sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 6px 0 4px; }
    .mg-sheet-tile {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 96px;
        padding: 12px 6px;
        border: 0;
        border-radius: 16px;
        background: #F7F8FA;
        color: var(--mg-ink) !important;
        font-family: inherit;
        font-size: 13px;
        font-weight: 500;
        line-height: 1.2;
        text-align: center;
        text-decoration: none !important;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .mg-sheet-tile:active { background: var(--mg-orange-soft); }
    .mg-sheet-tile.mg-on { background: var(--mg-orange-soft); color: var(--mg-orange-dark) !important; font-weight: 600; }
    .mg-sheet-tile.mg-on .mg-rail-ico { background: var(--mg-orange); border-color: var(--mg-orange); color: #fff; }
    .mg-sheet-tile:focus-visible, .mg-sheet-back:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: 2px; }
    .mg-sheet-back { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 4px; border: 0; background: none; font-family: inherit; font-size: 17px; font-weight: 600; color: var(--mg-ink); text-align: left; cursor: pointer; }
    .mg-sheet-back-arrow { width: 10px; height: 10px; margin-left: 6px; border-left: 2px solid var(--mg-ink); border-bottom: 2px solid var(--mg-ink); transform: rotate(45deg); flex: 0 0 auto; }
    .mg-sheet-detail .mg-sheet-links, .mg-sheet-results { padding: 4px 0 10px; }
    html.mg-sheet-open body { overflow: hidden; }
    .mg-sheet-head { display: flex; gap: 8px; align-items: center; padding: 14px 12px 8px; }
    .mg-sheet-search {
        flex: 1;
        min-width: 0;
        height: 46px;
        border: 1px solid #E1E4EA;
        border-radius: 12px;
        padding: 0 14px;
        font: inherit;
        font-size: 16px; /* 16 px : evite le zoom automatique a la saisie sur telephone */
        background: #F7F8FA;
        color: var(--mg-ink);
    }
    .mg-sheet-search:focus { outline: none; border-color: var(--mg-orange); box-shadow: 0 0 0 3px var(--mg-orange-soft); background: #fff; }
    .mg-sheet-close { width: 46px; height: 46px; flex: 0 0 auto; border: 1px solid var(--mg-line); border-radius: 12px; background: #fff; color: var(--mg-ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
    .mg-sheet-close svg { width: 22px; height: 22px; }
    .mg-sheet-close:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: 2px; }
    .mg-sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 12px 20px; }
    .mg-sheet-none { text-align: center; color: var(--mg-muted); padding: 28px 0; margin: 0; }
    .mg-sheet-group { border-bottom: 1px solid var(--mg-line); }
    .mg-sheet-group:last-child { border-bottom: 0; }
    .mg-sheet-group-head {
        width: 100%;
        min-height: 60px;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 8px 4px;
        border: 0;
        background: none;
        font-family: inherit;
        font-size: 16px;
        font-weight: 500;
        color: var(--mg-ink) !important;
        text-align: left;
        text-decoration: none !important;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .mg-sheet-group-label { flex: 1; min-width: 0; }
    .mg-sheet-group-head[aria-expanded="true"] .mg-rail-ico,
    .mg-sheet-group-head.mg-on .mg-rail-ico { background: var(--mg-orange); border-color: var(--mg-orange); color: #fff; }
    .mg-sheet-group-head:focus-visible { outline: 2px solid var(--mg-orange); outline-offset: -2px; border-radius: 12px; }
    .mg-sheet-chevron { width: 10px; height: 10px; border-right: 2px solid #9AA0AC; border-bottom: 2px solid #9AA0AC; transform: rotate(45deg); margin-right: 8px; transition: transform .15s; flex: 0 0 auto; }
    .mg-sheet-group-head[aria-expanded="true"] .mg-sheet-chevron { transform: rotate(-135deg); }
    .mg-sheet-links { padding: 0 0 10px 52px; }
    .mg-sheet-links a { padding: 12px 12px; font-size: 15.5px; }
    .mg-sheet-links .mg-panel-head { padding: 12px 12px 4px; font-size: 12.5px; color: var(--mg-muted); }
    #mg-sheet [hidden] { display: none !important; }

    /* En-tete compact : la marque, puis l'essentiel. Le reste est dans le menu. */
    html.mg-nav .theme-header-bg > div { padding: 8px 12px !important; }
    html.mg-nav .mg-brand { font-size: 16px; max-width: 46vw; }
    html.mg-nav .theme-header-bg #btnCalculator,
    html.mg-nav .theme-header-bg #view_todays_profit,
    html.mg-nav .theme-header-bg > div > div > i.fa-info-circle { display: none !important; }
    html.mg-nav .theme-header-bg > div > div > div:last-child { gap: 6px !important; }
}

/* Telephone : la caisse est deja dans la barre du bas, inutile de la repeter dans l'en-tete. */
@media (max-width: 1023px) {
    html.mg-nav .theme-header-bg a[href$="/pos/create"] { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
    .mg-rail-ico, .mg-sheet-chevron { transition: none; }
    html.mg-panel-open #mg-panel, html.mg-nav #mg-sheet:not([hidden]) { animation: none; }
}
@media print {
    #mg-nav, #mg-tabbar, #mg-sheet { display: none !important; }
}

/* Telephone : boutons de l'en-tete a la taille du doigt. */
@media (max-width: 1023px) {
    html.mg-nav .theme-header-bg > div > div > div:last-child > button,
    html.mg-nav .theme-header-bg > div > div > div:last-child > a:not([href$="/pos/create"]):not([href*="sub_type=repair"]),
    html.mg-nav .theme-header-bg > div > div > div:last-child > details > summary,
    html.mg-nav .theme-header-bg > div > div > div:last-child > li > a { min-height: 40px; min-width: 40px; display: inline-flex !important; align-items: center; justify-content: center; }
    html.mg-nav .theme-header-bg > div > div > div:last-child > .hide { display: none !important; }
}

/* Telephone : en-tete reduit a l'essentiel (marque, pointage, notifications, compte). */
@media (max-width: 1023px) {
    html.mg-nav .theme-header-bg > div > div > div:last-child > details:not(:last-child) { display: none !important; }
}

/* Barre du haut des modules (CRM, GRH, espace admin) : ses pages sont deja dans le menu. */
html.mg-nav.mg-module-nav section.no-print > nav.navbar-default { display: none !important; }

/* Colonne d'icones : elle se resserre quand l'ecran manque de hauteur, pour tout montrer. */
@media (min-width: 1024px) and (max-height: 1000px) {
    #mg-rail { padding: 8px 6px 10px; gap: 0; }
    .mg-rail-btn { padding: 4px 2px; gap: 3px; font-size: 10.5px; }
    .mg-rail-btn .mg-rail-ico { width: 34px; height: 34px; border-radius: 10px; }
    .mg-rail-btn .mg-rail-ico svg { width: 18px !important; height: 18px !important; }
}
@media (min-width: 1024px) and (max-height: 760px) {
    .mg-rail-btn { padding: 3px 2px; gap: 2px; font-size: 10px; }
    .mg-rail-btn .mg-rail-ico { width: 30px; height: 30px; border-radius: 9px; }
    .mg-rail-btn .mg-rail-ico svg { width: 16px !important; height: 16px !important; }
}
@media print {
    .mg-abo, .mg-brand, .mg-bulk-bar, #mg-selbar, #mgo-bar { display: none !important; }
}

/* ---------- Menu de gauche (ordinateur) : rubriques regroupees, reglages en bas ---------- */
@media (min-width: 1024px) {
    #mg-rail { gap: 1px; padding: 10px 8px 12px; }
    .mg-rail-btn { padding: 6px 2px; position: relative; }
    .mg-rail-label { overflow-wrap: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    /* Un filet separe les familles : vendre | acheter et stocker | suivre | regler. */
    .mg-rail-btn[data-g="achats"], .mg-rail-btn[data-g="contacts"], .mg-rail-btn[data-g="rapports"] { margin-top: 11px; }
    .mg-rail-btn[data-g="achats"]::before, .mg-rail-btn[data-g="contacts"]::before, .mg-rail-btn[data-g="rapports"]::before {
        content: ""; position: absolute; top: -6px; left: 18px; right: 18px; height: 1px; background: var(--mg-line);
    }
    /* Reglages (et Admin) restent tout en bas, toujours au meme endroit. */
    .mg-rail-btn[data-g="config"] { margin-top: auto; }
    .mg-rail-btn[data-g="config"]::before { content: ""; position: absolute; top: -6px; left: 18px; right: 18px; height: 1px; background: var(--mg-line); }
    .mg-rail-btn[data-g="rapports"] + .mg-rail-btn[data-g="config"] { padding-top: 12px; }
}

/* ---------- Abonnement : dans le menu du compte et en tete du menu telephone ---------- */
.mg-compte-abo { align-items: center !important; gap: 10px !important; margin-bottom: 4px; border: 1px solid #DDF1E6; background: #F1FAF5; }
.mg-compte-abo-txt, .mg-sheet-abo-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.mg-compte-abo-txt b, .mg-sheet-abo-txt b { font-weight: 600; color: var(--mg-ink); }
.mg-compte-abo-txt small, .mg-sheet-abo-txt small { font-size: 12.5px; font-weight: 400; color: #1E6B47; white-space: normal; }
.mg-etat-bientot, .mg-etat-attente { border-color: #FBE3C8 !important; background: #FFF6EA !important; }
.mg-etat-bientot small, .mg-etat-attente small { color: #9A5A0B !important; }
.mg-etat-bientot .mg-abo-dot, .mg-etat-attente .mg-abo-dot { background: #F08A24; }
.mg-etat-urgent, .mg-etat-expire, .mg-etat-aucun { border-color: #F6CFCF !important; background: #FDECEC !important; }
.mg-etat-urgent small, .mg-etat-expire small, .mg-etat-aucun small { color: #B02A2A !important; font-weight: 600; }
.mg-etat-urgent .mg-abo-dot, .mg-etat-expire .mg-abo-dot, .mg-etat-aucun .mg-abo-dot { background: #D64545; }
.mg-sheet-abo { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px; border: 1px solid #DDF1E6; border-radius: 16px; background: #F1FAF5; text-decoration: none !important; -webkit-tap-highlight-color: transparent; }
.mg-sheet-abo .mg-sheet-abo-txt { flex: 1 1 auto; }
.mg-sheet-abo .mg-sheet-abo-txt b { font-size: 15px; }
.mg-sheet-abo-go { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid #E1E4EA; font-size: 13.5px; font-weight: 600; color: var(--mg-ink); }
/* ================= Barre du haut (cote entreprise) : Nouveau, caisse, date, icones ================= */
html.mg-nav .theme-header-bg > div > div > div:last-child > button,
html.mg-nav .theme-header-bg > div > div > div:last-child > a,
html.mg-nav .theme-header-bg > div > div > div:last-child > details > summary { min-height: 40px; }
html.mg-nav .theme-header-bg .mg-top-ico { width: 40px; padding: 0 !important; }
html.mg-nav .theme-header-bg .mg-top-ico:hover, html.mg-nav .theme-header-bg .mg-top-nouveau > summary:hover { background: var(--mg-orange-soft) !important; box-shadow: inset 0 0 0 1px var(--mg-orange) !important; }
html.mg-nav .theme-header-bg .mg-top-nouveau > summary { gap: 6px !important; padding: 0 14px 0 10px !important; font-weight: 500; list-style: none; }
html.mg-nav .theme-header-bg .mg-top-nouveau > summary::-webkit-details-marker { display: none; }
html.mg-nav .theme-header-bg .mg-top-nouveau[open] > summary { background: var(--mg-orange-soft) !important; box-shadow: inset 0 0 0 1px var(--mg-orange) !important; }
html.mg-nav .theme-header-bg .mg-top-nouveau > ul { width: 232px !important; left: auto !important; right: 0 !important; border-radius: 14px !important; box-shadow: 0 18px 44px rgba(27, 29, 40, .16) !important; z-index: 1050 !important; }
html.mg-nav .theme-header-bg .mg-top-nouveau > ul a { min-height: 42px; font-size: 14.5px !important; color: var(--mg-ink) !important; }
html.mg-nav .theme-header-bg .mg-top-nouveau > ul a svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--mg-muted); }
html.mg-nav .theme-header-bg .mg-top-nouveau > ul a:hover { background: var(--mg-orange-soft) !important; }
html.mg-nav .theme-header-bg .mg-top-trait { height: 1px; margin: 6px 4px; background: var(--mg-line); }
html.mg-nav .theme-header-bg a.mg-top-caisse { background: var(--mg-orange) !important; color: #fff !important; box-shadow: none !important; padding: 0 16px !important; font-weight: 600 !important; }
html.mg-nav .theme-header-bg a.mg-top-caisse svg { color: #fff; }
html.mg-nav .theme-header-bg a.mg-top-caisse:hover { background: var(--mg-orange-dark) !important; color: #fff !important; }
html.mg-nav .theme-header-bg a.mg-top-caisse:focus-visible { outline: 3px solid var(--mg-ink); outline-offset: 2px; }
html.mg-nav .theme-header-bg .mg-top-date { display: none; align-items: center; gap: 7px; padding: 0 6px; border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 500; color: var(--mg-muted) !important; cursor: default; white-space: nowrap; }
html.mg-nav .theme-header-bg .mg-top-date svg { width: 18px; height: 18px; }
html.mg-nav .theme-header-bg .mg-top-date span::first-letter { text-transform: uppercase; }
@media (min-width: 1100px) { html.mg-nav .theme-header-bg .mg-top-date { display: inline-flex; } }
@media (max-width: 1023px) { html.mg-nav .theme-header-bg .mg-top-nouveau-txt { display: none; } html.mg-nav .theme-header-bg .mg-top-nouveau > summary { padding: 0 !important; width: 40px; } }
/* ===================== Colonne d'icones : plus calme (2026) =====================
   Au repos, pas de cadre autour des icones ; au survol, toute la case reagit ; la rubrique ouverte
   porte un fond doux, une icone orange et un repere a gauche. */
@media (min-width: 1024px) {
    #mg-rail { width: 84px; flex-basis: 84px; padding: 10px 8px 14px; gap: 4px; }
    .mg-rail-btn { position: relative; gap: 3px; padding: 8px 2px 7px; border-radius: 14px; font-size: 11.5px; color: #4A4F60 !important; transition: background-color .15s, color .15s; }
    .mg-rail-btn .mg-rail-ico { width: 36px; height: 30px; border: 0; border-radius: 10px; background: none; color: #4A4F60; }
    .mg-rail-btn .mg-rail-ico svg { width: 21px !important; height: 21px !important; }
    .mg-rail-btn:hover { background: #F4F5F8; color: var(--mg-ink) !important; }
    .mg-rail-btn:hover .mg-rail-ico, .mg-rail-btn.mg-open .mg-rail-ico { background: none; border: 0; color: var(--mg-ink); }
    .mg-rail-btn.mg-open { background: #F4F5F8; color: var(--mg-ink) !important; }
    .mg-rail-btn[aria-current="true"] { background: var(--mg-orange-soft); color: var(--mg-orange-dark) !important; font-weight: 600; }
    .mg-rail-btn[aria-current="true"] .mg-rail-ico, .mg-rail-btn[aria-current="true"].mg-open .mg-rail-ico, .mg-rail-btn[aria-current="true"]:hover .mg-rail-ico { background: none; color: var(--mg-orange-dark); }
    .mg-rail-btn[aria-current="true"]::before { content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mg-orange); }
    .mg-rail-btn:focus-visible { outline: 3px solid var(--mg-ink); outline-offset: -2px; }
    #mg-rail hr, #mg-rail .mg-rail-sep { margin: 6px 14px; border: 0; border-top: 1px solid var(--mg-line); height: 0; background: none; }
    #mg-panel { left: 90px; border-radius: 16px; padding: 12px 8px; }
    #mg-panel a { min-height: 38px; display: flex; align-items: center; }
}
@media (prefers-reduced-motion: reduce) { .mg-rail-btn { transition: none; } }

/* ===================== Menu du compte (en haut a droite) =====================
   Plus large, le nom sur une ligne, des lignes faciles a toucher ; "Deconnexion" a part, en bas. */
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) { width: 264px !important; padding: 8px !important; border-radius: 16px !important; box-shadow: 0 16px 40px rgba(27, 29, 40, .16), 0 2px 6px rgba(27, 29, 40, .06) !important; z-index: 1046 !important; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) > div:first-child { padding: 10px 12px 12px !important; margin-bottom: 4px; border-bottom: 1px solid var(--mg-line); gap: 10px !important; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) > div:first-child p { margin: 0; white-space: nowrap; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) > div:first-child p:first-child { font-size: 12.5px !important; color: var(--mg-muted); }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) > div:first-child p + p { font-size: 15px !important; font-weight: 600 !important; color: var(--mg-ink) !important; overflow: hidden; text-overflow: ellipsis; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) > div:first-child > svg { flex: 0 0 auto; width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: var(--mg-orange-soft); color: var(--mg-orange-dark); }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) li { list-style: none; margin: 0; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) li > a { min-height: 46px; padding: 8px 12px !important; border-radius: 12px !important; font-size: 14.5px !important; color: var(--mg-ink) !important; gap: 10px !important; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) li > a:focus-visible { outline: 3px solid var(--mg-ink); outline-offset: -2px; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) li > a.mg-compte-abo { margin-bottom: 4px; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) li:has(> a[href*="/logout"]) { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--mg-line); }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) a[href*="/logout"] { color: #B02A2A !important; }
html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) a[href*="/logout"]:hover { background: #FDECEC !important; }
@media (max-width: 640px) {
    /* Telephone : le menu se pose sous la barre, sur presque toute la largeur de l'ecran. */
    html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) { position: fixed !important; top: calc(58px + env(safe-area-inset-top, 0px)) !important; right: 12px !important; left: 12px !important; width: auto !important; margin: 0 !important; padding: 10px !important; }
    html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) li > a { min-height: 52px; font-size: 16px !important; }
    html.mg-nav .theme-header-bg details > ul:has(a[href*="/logout"]) > div:first-child p + p { font-size: 16px !important; }
    html.mg-nav .theme-header-bg details[open]:has(> ul a[href*="/logout"])::before { content: ""; position: fixed; inset: 0; background: rgba(27, 29, 40, .28); z-index: 1045; }
    html.mg-nav .theme-header-bg details[open]:has(> ul a[href*="/logout"]) > summary { position: relative; z-index: 1046; }
}

/* Colonne d'icones, retouche : le libelle "Point de vente" tient en entier ; le repere de la rubrique ouverte
   n'ecrase plus le filet de separation (qui utilise deja ::before). */
@media (min-width: 1024px) {
    #mg-rail { width: 92px; flex-basis: 92px; padding-left: 6px; padding-right: 6px; }
    .mg-rail-btn { font-size: 11px; }
    .mg-rail-label { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: normal; word-break: normal; hyphens: none; max-width: none; line-height: 1.2; }
    .mg-rail-btn[aria-current="true"]::before { content: none; }
    .mg-rail-btn[data-g="achats"][aria-current="true"]::before, .mg-rail-btn[data-g="contacts"][aria-current="true"]::before, .mg-rail-btn[data-g="rapports"][aria-current="true"]::before { content: ""; position: absolute; top: -6px; bottom: auto; left: 18px; right: 18px; width: auto; height: 1px; border-radius: 0; background: var(--mg-line); }
    .mg-rail-btn[aria-current="true"]::after { content: ""; position: absolute; left: -6px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--mg-orange); }
    #mg-panel { left: 98px; }
    #mg-panel::before { left: 84px; }
}

/* ===================== Haut de page : la marque a sa place en tete de la colonne de gauche =====================
   Avant, la colonne commencait directement par "Accueil", collee tout en haut. Elle s'ouvre maintenant par le logo,
   dans une case de la hauteur de la barre du haut : le filet sous la barre se prolonge d'un bord a l'autre. */
@media (min-width: 1024px) {
    #mg-rail { padding-top: 0; }
    #mg-rail::before {
        content: ""; flex: 0 0 60px; height: 60px; margin: 0 -6px 8px; position: sticky; top: 0; z-index: 2;
        border-bottom: 1px solid var(--mg-line);
        background: url(mg-symbole.png) center 11px / 38px 38px no-repeat, #fff;
    }
    /* Mode assistance : le bandeau sombre du haut se prolonge au-dessus du logo, pour que les lignes restent alignees. */
    html.mg-avec-bandeau #mg-rail::before {
        flex-basis: calc(60px + var(--mg-bandeau-h, 0px)); height: calc(60px + var(--mg-bandeau-h, 0px));
        background-position: center calc(11px + var(--mg-bandeau-h, 0px)), 0 0;
        box-shadow: inset 0 var(--mg-bandeau-h, 0px) 0 #14161F;
    }
    /* Le logo est dans la colonne : dans la barre du haut il ne reste que le nom de l'entreprise. */
    html.mg-nav .theme-header-bg .mg-brand-bars { display: none; }
    html.mg-nav .theme-header-bg > div { padding-left: 20px !important; padding-right: 20px !important; min-height: 60px; }
    html.mg-nav .theme-header-bg { border-bottom: 1px solid var(--mg-line) !important; box-shadow: none !important; }
    /* Un peu d'air entre la barre du haut et le contenu. */
    html.mg-nav section.content-header { padding-top: 22px !important; }
    html.mg-nav section.content:first-of-type:not(.content-header + .content) { padding-top: 22px; }
    html.mg-nav section.content-header, html.mg-nav section.content { padding-left: 24px !important; padding-right: 24px !important; }
}

/* Telephone et tablette : quand la pastille d'abonnement est affichee, il n'y a pas la place pour le nom de
   l'entreprise. On garde le logo seul (jamais recouvert), puis la pastille, qui se raccourcit si besoin. */
@media (max-width: 1023px) {
    html.mg-nav .theme-header-bg .mg-brand { flex: 0 0 auto; min-width: 26px; }
    html.mg-nav .theme-header-bg .mg-brand-name { min-width: 0; }
    html.mg-nav .theme-header-bg:has(.mg-abo:not([hidden]):not(.mg-abo-ok)) .mg-brand { max-width: none; margin-right: 8px; }
    html.mg-nav .theme-header-bg:has(.mg-abo:not([hidden]):not(.mg-abo-ok)) .mg-brand-name { display: none; }
    html.mg-nav .theme-header-bg .mg-abo { flex: 0 1 auto; min-width: 0; margin: 0 auto 0 0; }
    html.mg-nav .theme-header-bg .mg-abo .mg-abo-court { min-width: 0; }
}
@media (min-width: 600px) and (max-width: 1023px) {
    /* Tablette : assez de place pour garder aussi le nom, raccourci. */
    html.mg-nav .theme-header-bg:has(.mg-abo:not([hidden]):not(.mg-abo-ok)) .mg-brand { flex: 0 1 auto; max-width: 30vw; }
    html.mg-nav .theme-header-bg:has(.mg-abo:not([hidden]):not(.mg-abo-ok)) .mg-brand-name { display: inline; }
}

/* Telephone : la date du jour laisse sa place (le telephone l'affiche deja), pour que la pastille d'abonnement
   se lise en entier et que les trois boutons de droite restent bien visibles et faciles a toucher. */
@media (max-width: 599px) {
    html.mg-nav .theme-header-bg .mg-top-date { display: none !important; }
    html.mg-nav .theme-header-bg .mg-abo { padding: 8px 12px; font-size: 13px; min-height: 36px; }
    html.mg-nav .theme-header-bg > div > div > div:last-child { flex: 0 0 auto; }
}
@media (min-width: 600px) and (max-width: 767px) {
    html.mg-nav .theme-header-bg:has(.mg-abo:not([hidden]):not(.mg-abo-ok)) .mg-top-date { display: none !important; }
}

/* Application Android : reglage du verrouillage, en bas du menu « Plus » */
.mg-verrou { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; padding: 14px; border: 1px solid var(--mg-line, #E7E9EE); border-radius: 14px; background: #fff; }
.mg-verrou-ico { flex: 0 0 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--mg-orange-soft, #FFF1E5); color: var(--mg-orange-dark, #E27322); }
.mg-verrou-ico svg { width: 22px; height: 22px; }
.mg-verrou-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mg-verrou-txt b { font-size: 15px; font-weight: 600; color: var(--mg-ink, #1B1D28); } .mg-verrou-txt small { font-size: 12.5px; line-height: 1.35; color: #7A8092; }
.mg-verrou-b { flex: 0 0 52px; width: 52px; height: 32px; padding: 3px; border: 0; border-radius: 999px; background: #D8DCE3; transition: background .15s; }
.mg-verrou-b i { display: block; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(27, 29, 40, .25); transition: transform .15s; }
.mg-verrou-b[aria-checked="true"] { background: var(--mg-orange, #F5883A); } .mg-verrou-b[aria-checked="true"] i { transform: translateX(20px); }
.mg-verrou-b:disabled { opacity: .5; }
.mg-verrou-b:focus-visible { outline: 2px solid var(--mg-orange, #F5883A); outline-offset: 2px; }

/* Barre du bas : la caisse au centre, mise en avant */
@media (max-width: 1023px) { .mg-tab.mg-tab-caisse { color: var(--mg-orange-dark) !important; font-weight: 600; } .mg-tab.mg-tab-caisse .mg-tab-ico { background: var(--mg-orange); color: #fff; box-shadow: 0 2px 6px rgba(245, 136, 58, .35); } .mg-tab-label { font-size: 11px; } }

/* La date du bandeau : jamais sur telephone ni tablette, ni dans l'application (demande du proprietaire). */
/* :not(#mg-0) donne a la regle le poids qu'il faut pour passer devant celle qui affiche tous les boutons de l'en-tete. */
@media (max-width: 1023px) { html.mg-nav:not(#mg-0) .theme-header-bg .mg-top-date, html:not(#mg-0) .theme-header-bg .mg-top-date.mg-top-date { display: none !important; } }
html.mg-appli-android .theme-header-bg .mg-top-date.mg-top-date { display: none !important; }
