/* Afrilink Stocks – administration RGZ.
   Même système visuel que l'espace admin d'Axi (barre latérale sombre, cartes arrondies, indicateurs à icône),
   aux couleurs de la charte Afrilink : magenta pour la marque, orange « 4G » pour l'accent, bleu du logo en secondaire. */
:root {
    --brand: #a21f63; --brand-hover: #7e164c; --brand-soft: #fbe8f1; --brand-ink: #7e164c; --logo: #f0864b;
    --gold: #b96a00; --gold-soft: #fdefd3; --ok: #17864b; --ok-soft: #ddf5e8; --info: #2d7bcf; --info-soft: #e3eefa;
    --plum: #2d7bcf; --plum-soft: #e3eefa; --danger: #c8192a; --danger-soft: #fee2e2;
    --ink: #211a26; --muted: #6c6476; --bg: #f1ecf2; --surface: #fbf9fb; --surface-2: #f3eef4; --border: #e3d9e5;
    --side: #2a0b1c; --side-2: #4a1030; --side-ink: #f1dce7; --side-on: #a21f63;
    --shadow: 0 1px 2px rgba(50, 12, 34, .05), 0 10px 28px rgba(50, 12, 34, .07); --radius: 20px;
    --hero: linear-gradient(120deg, #5e0f38 0%, #a21f63 58%, #c23a78 100%);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; color: var(--brand-hover); }
a, button { text-decoration: none !important; }
h1 { font-size: clamp(25px, 3.2vw, 34px); line-height: 1.18; margin: 0 0 6px; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 19px; margin: 0 0 14px; }
.muet { color: var(--muted); }
.petit { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.droite { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---- Structure : barre latérale + page */
.shell { display: flex; min-height: 100vh; }
.page { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side { width: 268px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); background-image: linear-gradient(180deg, var(--side) 60%, var(--side-2)); color: var(--side-ink); z-index: 40; }
.side-head { padding: 24px 24px 16px; }
.logo { display: inline-flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.02em; white-space: nowrap; line-height: 1.1; }
.logo:hover { text-decoration: none; }
.logo img { width: 40px; height: 40px; border-radius: 12px; display: block; }
.logo small { display: block; color: var(--logo); font-size: 12.5px; font-weight: 700; letter-spacing: .04em; margin-top: 2px; }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 14px 14px; scrollbar-width: none; }
.side-nav::-webkit-scrollbar { display: none; }
.side-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #c39bb1; margin: 20px 12px 8px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--side-ink); font-size: 15px; font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s; }
.side-nav a span:first-of-type { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav a svg { flex-shrink: 0; opacity: .8; }
.side-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.side-nav a.on { background: var(--side-on); color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgba(162, 31, 99, .5); }
.side-nav a.on svg { opacity: 1; }
.side-user { border-top: 1px solid rgba(255, 255, 255, .09); padding: 14px; display: flex; align-items: center; gap: 10px; }
.side-who { flex: 1; min-width: 0; color: inherit; display: flex; align-items: center; gap: 10px; border-radius: 12px; padding: 4px; }
.side-who:hover { text-decoration: none; background: rgba(255, 255, 255, .06); }
.side-who strong { display: block; color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-who small { display: block; color: #c39bb1; font-size: 12px; }
.side-user form { margin: 0; }
.side-out { background: none; border: 0; color: #c39bb1; cursor: pointer; width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.side-out:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.pill { display: inline-flex; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--logo); color: #5e0f38; font-size: 12px; font-weight: 800; align-items: center; justify-content: center; }
.top { display: none; align-items: center; justify-content: space-between; background: var(--side); padding: 12px 16px; position: sticky; top: 0; z-index: 30; }
.burger { background: none; border: 0; color: #fff; padding: 8px; border-radius: 10px; cursor: pointer; display: inline-flex; }
.scrim { display: none; }
main { width: 100%; max-width: 1320px; margin: 0 auto; padding: 32px clamp(16px, 3vw, 40px) 64px; }
.haut { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.haut .muet { font-size: 16px; max-width: 760px; }
.haut .actions, .actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---- Bandeau du tableau de bord */
.hero { position: relative; overflow: hidden; background: var(--hero); color: #fff; border-radius: 26px; padding: clamp(24px, 3.4vw, 38px) clamp(22px, 3.4vw, 42px); margin-bottom: 24px; box-shadow: 0 18px 40px rgba(162, 31, 99, .26); }
.hero-eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--logo); margin: 0 0 8px; }
.hero h1 { color: #fff; font-size: clamp(26px, 3.6vw, 38px); margin: 0 0 8px; }
.hero p { color: #f8dcea; margin: 0; max-width: 620px; font-size: 16px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero-actions a { display: inline-flex; align-items: center; gap: 8px; background: #fff; color: var(--brand-ink); font-weight: 700; padding: 10px 16px; border-radius: 12px; min-height: 44px; }
.hero-actions a.alt { background: rgba(255, 255, 255, .16); color: #fff; }
.hero-actions a:hover { text-decoration: none; opacity: .92; }

/* ---- Cartes et grilles */
.carte { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.carte.serree { padding: 0; overflow: hidden; }
.carte .titre-panneau { padding: 20px 24px 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.carte .titre-panneau h2 { margin: 0; }
.grille { display: grid; gap: 18px; margin-bottom: 24px; }
.grille > .carte { margin-bottom: 0; }
/* Cartes côte à côte toujours de la même hauteur */
.grille.c2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: stretch; }
.grille.c2 > * { margin-bottom: 0; }
.grille.c3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grille.c4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* Indicateurs : icône, libellé, valeur */
.chiffre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin: 0; padding: 22px; position: relative; overflow: hidden; --c: var(--brand); --cs: var(--brand-soft); color: inherit; display: block; transition: transform .15s, border-color .15s; }
.grille > .chiffre:nth-child(4n+2) { --c: var(--ok); --cs: var(--ok-soft); }
.grille > .chiffre:nth-child(4n+3) { --c: var(--gold); --cs: var(--gold-soft); }
.grille > .chiffre:nth-child(4n) { --c: var(--plum); --cs: var(--plum-soft); }
.chiffre.rouge { --c: var(--danger) !important; --cs: var(--danger-soft) !important; }
.chiffre .ic { width: 44px; height: 44px; border-radius: 14px; background: var(--cs); color: var(--c); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.chiffre .libelle { color: var(--muted); font-size: 14px; font-weight: 600; }
.chiffre .valeur { font-size: clamp(22px, 2.3vw, 32px); font-weight: 800; letter-spacing: -.02em; margin: 2px 0; line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chiffre .sous { color: var(--muted); font-size: 13px; }
a.chiffre:hover { border-color: var(--c); transform: translateY(-2px); text-decoration: none; }

/* ---- Tableaux */
.table-defile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.liste { border-collapse: collapse; width: 100%; }
table.liste th, table.liste td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.liste th { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; background: var(--surface-2); }
table.liste tr:last-child td { border-bottom: 0; }
table.liste td.droite, table.liste th.droite { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.liste tbody tr:hover { background: var(--surface-2); }
table.liste td a { font-weight: 600; }
table.liste td a:hover { color: var(--brand-hover); }
table.liste tr.periode td, table.liste tr.periode:hover td { background: var(--brand-soft); color: var(--brand-ink); font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 9px 16px; }
.vide { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---- Cartons dépliables */
details.carton { border-bottom: 1px solid var(--border); }
.liste-cartons { min-width: 860px; }
details.carton:last-of-type { border-bottom: 0; }
details.carton > summary { display: grid; grid-template-columns: 26px minmax(170px, 1.3fr) minmax(110px, 1fr) 90px minmax(180px, 2fr) 140px; gap: 12px; align-items: center; padding: 14px 16px; cursor: pointer; list-style: none; }
details.carton > summary::-webkit-details-marker { display: none; }
details.carton > summary::before { content: "+"; width: 24px; height: 24px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
details.carton[open] > summary::before { content: "–"; background: var(--brand); color: #fff; }
details.carton > summary:hover { background: var(--surface-2); }
details.carton .contenu-carton { padding: 6px 16px 16px 54px; background: var(--surface-2); border-top: 1px solid var(--border); }
details.carton .contenu-carton table.liste td { padding: 8px 12px; }
.compte { font-weight: 800; font-variant-numeric: tabular-nums; }
.compte.plein { color: var(--ok); }
.repartition { display: flex; gap: 6px; flex-wrap: wrap; }
.titre-periode { padding: 9px 16px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.onglets { display: flex; gap: 8px; flex-wrap: wrap; }
.onglets a { padding: 9px 16px; color: var(--muted); font-weight: 600; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.onglets a:hover { text-decoration: none; color: var(--ink); }
.onglets a.actif { color: #fff; background: var(--brand); border-color: var(--brand); }

/* ---- Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.vert { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.bleu { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.orange { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.badge.violet { background: var(--plum-soft); color: var(--plum); border-color: transparent; }
.badge.rouge { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--brand); background: var(--brand); color: #fff; border-radius: 12px; padding: 9px 18px; font: inherit; font-weight: 700; cursor: pointer; min-height: 44px; white-space: nowrap; transition: background .12s, opacity .12s; }
.btn:hover { background: var(--brand-hover); border-color: var(--brand-hover); text-decoration: none; }
.btn.clair { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn.clair:hover { background: var(--surface-2); }
.btn.vert { background: var(--logo); border-color: var(--logo); color: #5e0f38; }
.btn.vert:hover { background: #e2733a; border-color: #e2733a; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: 14px; }
form.inline { display: inline; margin: 0; }

/* ---- Formulaires */
label { display: block; font-weight: 600; font-size: 15px; margin: 0 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
    font: inherit; font-size: 16px; color: var(--ink); background: #fdfbfd; border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; width: 100%; min-height: 48px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.champ { margin-bottom: 16px; }
.champ .aide { font-size: 13px; color: var(--muted); margin-top: 5px; }
.champ .erreur { font-size: 13px; color: var(--danger); margin-top: 5px; }
.case { display: flex; gap: 10px; align-items: center; font-weight: 500; cursor: pointer; margin: 0; }
.case input { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; flex-shrink: 0; }
.formulaire { max-width: none; }
.avec-aide { display: grid; gap: 20px; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.avec-aide > .carte { margin-bottom: 0; }
.aide-carte h2 { font-size: 16px; }
.aide-carte p, .aide-carte li { color: var(--muted); font-size: 14px; }
.aide-carte ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.aide-carte dl { margin-top: 6px; }
.filtres .reinit { align-self: flex-end; min-height: 48px; display: inline-flex; align-items: center; padding: 0 6px; font-weight: 600; color: var(--muted); }
.filtres .reinit:hover { color: var(--brand); }
@media (max-width: 1000px) { .avec-aide { grid-template-columns: 1fr; } }
.deux { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.filtres { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 20px; }
.filtres > div { flex: 1 1 180px; max-width: 260px; }
.filtres > div.boutons { flex: 0 0 auto; max-width: none; display: flex; gap: 10px; }

/* ---- Messages */
.alerte { padding: 14px 16px; border-radius: 14px; margin-bottom: 20px; border: 1px solid var(--border); border-left: 5px solid var(--ok); background: var(--surface); box-shadow: var(--shadow); }
.alerte.erreur { border-left-color: var(--danger); }
.alerte ul { margin: 0; padding-left: 18px; }
#toasts { position: fixed; right: 16px; top: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { position: relative; overflow: hidden; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-left: 5px solid var(--ok); border-radius: 14px; padding: 14px 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, .16); cursor: pointer; }
.toast.err { border-left-color: var(--danger); }
.toast::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: currentColor; opacity: .25; transform-origin: left; animation: decompte 4s linear forwards; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .25s; }
@keyframes decompte { to { transform: scaleX(0); } }
.signal { display: grid; grid-template-columns: 12px 1fr auto; gap: 14px; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--border); color: inherit; }
.signal:last-child { border-bottom: 0; }
a.signal:hover { background: var(--surface-2); text-decoration: none; }
.signal .point { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.signal.danger .point { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.signal strong { display: block; }
.signal .nombre { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---- Fenêtre de confirmation */
dialog.confirmation { border: 0; border-radius: 20px; padding: 26px; max-width: min(440px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(42, 8, 28, .35); color: var(--ink); }
dialog.confirmation::backdrop { background: rgba(42, 8, 28, .55); }
dialog.confirmation h2 { margin: 0 0 8px; font-size: 20px; }
dialog.confirmation p { margin: 0 0 20px; color: var(--muted); }
dialog.confirmation .actions { justify-content: flex-end; }

/* ---- Graphiques */
.barres .rang { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 12px; align-items: center; padding: 7px 0; }
.barres .piste { background: var(--brand-soft); border-radius: 99px; height: 10px; overflow: hidden; }
.barres .piste i { display: block; height: 100%; background: var(--brand); border-radius: 99px; min-width: 3px; }
.barres .rang.vert .piste i { background: var(--ok); }
.colonnes { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.colonnes .col { flex: 1; min-width: 6px; max-width: 44px; background: var(--brand); border-radius: 6px 6px 0 0; position: relative; }
.colonnes .col:hover { background: var(--brand-hover); }
.colonnes .col span { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 8px; white-space: nowrap; display: none; z-index: 2; }
.colonnes .col:hover span { display: block; }
.axe { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

.fiche { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 10px 18px; margin: 0; }
.fiche dt { color: var(--muted); }
.fiche dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.histo { list-style: none; margin: 0; padding: 0; }
.histo li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--border); margin-left: 6px; }
.histo li:last-child { border-left-color: transparent; padding-bottom: 0; }
.histo li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.pagination { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 14px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .liens { display: flex; gap: 10px; }

/* ---- Pages sans session */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--side); background-image: linear-gradient(160deg, var(--side) 40%, var(--side-2)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 28px; }
.auth-side h2 { font-size: 34px; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; max-width: 12em; }
.auth-side p { color: #ecc9da; font-size: 17px; margin: 0; max-width: 28em; }
.auth-who { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth-who li { display: flex; gap: 14px; align-items: center; color: #fff; font-weight: 600; }
.auth-who li svg { color: var(--logo); flex-shrink: 0; }
.auth-who small { display: block; color: #d9a9c1; font-weight: 400; font-size: 14px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h1 { font-size: 30px; }
.auth-box .btn { width: 100%; min-height: 54px; font-size: 17px; border-radius: 14px; margin-top: 4px; }
.auth-box .bas { text-align: center; margin-top: 18px; font-weight: 600; }

@media (max-width: 1060px) {
    .top { display: flex; }
    .side { position: fixed; left: 0; top: 0; bottom: 0; height: auto; transform: translateX(-100%); transition: transform .22s ease-out; }
    .side.open { transform: none; box-shadow: 0 0 48px rgba(0, 0, 0, .4); }
    .side.open ~ .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(42, 8, 28, .5); border: 0; }
}
@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .auth-side { padding: 24px 20px; gap: 14px; }
    .auth-side h2 { font-size: 26px; }
    .auth-who { display: none; }
}
@media (max-width: 700px) {
    .grille.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .chiffre { padding: 16px; }
    .carte { padding: 18px; }
    .fiche { grid-template-columns: 1fr; gap: 2px 0; }
    .fiche dd { margin-bottom: 10px; }
}
/* Champ mot de passe avec l'œil à l'intérieur, à droite */
.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 52px; }
.champ-mdp .oeil { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 44px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.champ-mdp .oeil:hover { color: var(--brand); background: var(--brand-soft); }
@media print { .side, .top, .filtres, .haut .actions, .pagination { display: none; } }
