/* ==========================================================================
   TBS Work — design system
   Brand colours sampled from the real TBS logo:
     navy #223453   gold #EDAE41
   Mobile-first. Every breakpoint is a min-width enhancement.
   ========================================================================== */

/* ------------------------------------------------------------------ tokens */
:root {
    /* brand */
    --navy-900: #131f33;
    --navy-800: #1a2942;
    --navy-700: #223453;
    --navy-600: #2c4269;
    --navy-500: #3a5586;
    --navy-400: #5b76a3;
    --navy-100: #e6ebf3;
    --navy-50:  #f2f5f9;

    --gold-600: #c88f22;
    --gold-500: #EDAE41;
    --gold-400: #f3c26e;
    --gold-100: #fdf3e0;

    /* semantic */
    --green-600: #15803d;
    --green-500: #16a34a;
    --green-100: #dcfce7;
    --red-600:   #be123c;
    --red-500:   #e11d48;
    --red-100:   #ffe4e6;
    --slate-600: #475569;
    --slate-100: #eef2f6;

    /* surfaces (light) */
    --bg:            #f4f6fa;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --surface-hover: #f1f5f9;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;

    /* text */
    --text:      #16233a;
    --text-soft: #56637a;
    --text-mute: #8a94a6;
    --on-brand:  #ffffff;

    /* sidebar */
    --side-bg:      var(--navy-700);
    --side-text:    #c8d3e6;
    --side-active:  rgba(237, 174, 65, .16);
    --side-hover:   rgba(255, 255, 255, .07);

    /* shape */
    --r-sm: 8px;
    --r:    12px;
    --r-lg: 16px;
    --r-xl: 20px;

    --shadow-xs: 0 1px 2px rgba(16, 27, 47, .06);
    --shadow-sm: 0 1px 3px rgba(16, 27, 47, .08), 0 1px 2px rgba(16, 27, 47, .04);
    --shadow:    0 4px 14px rgba(16, 27, 47, .08);
    --shadow-lg: 0 16px 40px rgba(16, 27, 47, .16);

    --side-w: 258px;
    --topbar-h: 60px;

    --fast: 140ms cubic-bezier(.4, 0, .2, 1);

    color-scheme: light;
}

html[data-theme="dark"] {
    --bg:            #0d1526;
    --surface:       #14203a;
    --surface-2:     #1a2a49;
    --surface-hover: #1f3153;
    --border:        #26385c;
    --border-strong: #35507d;

    --text:      #e8eefa;
    --text-soft: #a7b6d0;
    --text-mute: #7386a5;

    --side-bg:   #0a1222;
    --side-text: #b9c7de;

    --navy-100: #1f3153;
    --navy-50:  #182744;
    --slate-100: #1c2b48;
    --green-100: #10301f;
    --red-100:   #3a1220;
    --gold-100:  #3a2c12;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow:    0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);

    color-scheme: dark;
}

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0 0 .8em; }
a { color: var(--navy-600); text-decoration: none; }
a:hover { color: var(--gold-600); }
html[data-theme="dark"] a { color: #a9c1ea; }
html[data-theme="dark"] a:hover { color: var(--gold-400); }
img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }

:focus-visible {
    outline: 2px solid var(--gold-500);
    outline-offset: 2px;
    border-radius: 4px;
}

.ic { width: 20px; height: 20px; flex: 0 0 auto; }
.ic-sm { width: 16px; height: 16px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =============================================================== app shell */
.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--side-w);
    background: var(--side-bg);
    color: var(--side-text);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--fast);
    box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }

.side-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    min-height: var(--topbar-h);
}
/* The TBS mark is navy on transparent, so on dark surfaces it sits on a white
   chip rather than being recoloured — the logo itself is never altered. */
.brand-chip {
    flex: 0 0 auto;
    background: #fff;
    border-radius: 9px;
    padding: 5px 7px;
    display: grid;
    place-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.brand-chip img { width: 52px; height: auto; display: block; }
.side-brand .bn { font-weight: 750; color: #fff; font-size: 16px; letter-spacing: -.02em; line-height: 1.1; }
.side-brand .bs { font-size: 11px; color: var(--gold-500); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.side-close {
    margin-left: auto; background: none; border: 0; color: var(--side-text);
    padding: 6px; border-radius: var(--r-sm); cursor: pointer;
}
.side-close:hover { background: var(--side-hover); color: #fff; }

/* overflow-x must stay hidden: a visible one would let the active marker
   create a horizontal scroll area and clip the icons. */
.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 20px; }
.side-label {
    font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
    color: rgba(255, 255, 255, .38); font-weight: 700;
    padding: 14px 10px 6px;
}
.side-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; margin-bottom: 2px;
    border-radius: 10px;
    color: var(--side-text); font-size: 14.5px; font-weight: 500;
    transition: background var(--fast), color var(--fast);
    position: relative;
}
.side-link:hover { background: var(--side-hover); color: #fff; }
.side-link.active { background: var(--side-active); color: #fff; font-weight: 600; }
.side-link.active::before {
    content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-500);
}
.side-link.active .ic { color: var(--gold-500); }
.side-link .pill {
    margin-left: auto; background: var(--gold-500); color: var(--navy-900);
    font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
}

.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user { display: flex; align-items: center; gap: 10px; }
.side-user .meta { min-width: 0; }
.side-user .nm { color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .rl { font-size: 11.5px; color: rgba(255, 255, 255, .5); }
.side-user .out {
    margin-left: auto; color: var(--side-text); padding: 7px; border-radius: 8px;
    background: rgba(255, 255, 255, .06);
}
.side-user .out:hover { background: var(--red-500); color: #fff; }

.scrim {
    position: fixed; inset: 0; background: rgba(9, 16, 30, .55);
    z-index: 55; opacity: 0; pointer-events: none; transition: opacity var(--fast);
    backdrop-filter: blur(2px);
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* -------------------------------------------------------------- top bar */
.main { min-width: 0; }

.topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; min-width: 38px;
    border: 1px solid transparent; background: transparent;
    border-radius: 10px; color: var(--text-soft); cursor: pointer;
    transition: background var(--fast), color var(--fast);
    position: relative;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn .dot {
    position: absolute; top: 7px; right: 7px;
    min-width: 16px; height: 16px; padding: 0 4px;
    background: var(--red-500); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px;
    border-radius: 99px; text-align: center;
    border: 2px solid var(--surface);
}
.topbar-title { font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------- language switch */
.lang-switch {
    display: inline-flex; align-items: center; gap: 2px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 99px; padding: 2px; flex: 0 0 auto;
}
.lang-switch a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 30px; padding: 0 11px;
    border-radius: 99px; font-size: 12.5px; font-weight: 650;
    color: var(--text-soft); white-space: nowrap; line-height: 1;
    transition: background var(--fast), color var(--fast);
}
.lang-switch a:hover { color: var(--text); background: var(--surface-hover); }
.lang-switch a.on { background: var(--navy-700); color: #fff; }
html[data-theme="dark"] .lang-switch a.on { background: var(--gold-500); color: var(--navy-900); }

/* Très petits téléphones (320 px) : la barre du haut dépassait de 2 px. */
@media (max-width: 359px) {
    .topbar { gap: 6px; padding: 0 10px; }
    .lang-switch a { padding: 0 8px; }
}

.lang-switch-auth {
    display: flex; justify-content: center; margin: 18px auto 0; width: max-content;
}
.lang-switch-auth a { min-height: 34px; padding: 0 14px; font-size: 13px; }

/* Darija: keep the LTR layout, but let each paragraph pick its own direction
   so mixed Arabic/French sentences read naturally. */
html[data-lang="dz"] p,
html[data-lang="dz"] li,
html[data-lang="dz"] .sub,
html[data-lang="dz"] .hint,
html[data-lang="dz"] .note,
html[data-lang="dz"] .empty .t,
html[data-lang="dz"] .empty .s,
html[data-lang="dz"] .item .m,
html[data-lang="dz"] .alert > div,
html[data-lang="dz"] .card-foot,
html[data-lang="dz"] .guide-body,
html[data-lang="dz"] .help-body,
html[data-lang="dz"] .modal-body,
html[data-lang="dz"] td {
    unicode-bidi: plaintext;
}
.topbar-spacer { flex: 1; }
.topbar .brand-mini { display: flex; align-items: center; gap: 8px; }
.topbar .brand-mini img { width: 58px; height: auto; }
html[data-theme="dark"] .topbar .brand-mini img {
    background: #fff; border-radius: 7px; padding: 3px 5px;
}

/* ------------------------------------------------------------- container */
.page {
    padding: 18px 14px 76px;
    max-width: 1360px;
    margin: 0 auto;
    width: 100%;
}

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-start;
    gap: 12px; margin-bottom: 18px;
}
.page-head .ttl { font-size: 22px; }
.page-head .sub { color: var(--text-soft); font-size: 14px; margin: 3px 0 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* ------------------------------------------------------------------ cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}
.card-pad { padding: 16px; }
.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { font-size: 15.5px; font-weight: 650; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 10px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid { display: grid; gap: 14px; }
.g-1 { grid-template-columns: 1fr; }
.g-2, .g-3, .g-4 { grid-template-columns: 1fr; }

/* ------------------------------------------------------------- stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 14px;
    box-shadow: var(--shadow-xs);
    position: relative; overflow: hidden;
}
/* padding-right keeps the label clear of the absolutely-placed icon. */
.stat .lbl {
    font-size: 12.5px; color: var(--text-soft); font-weight: 500;
    display: flex; align-items: center; gap: 6px;
    padding-right: 40px; min-height: 34px; line-height: 1.3;
}
.stat .val { font-size: 27px; font-weight: 700; letter-spacing: -.03em; margin-top: 4px; line-height: 1.1; }
.stat .hint { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.stat .spark {
    position: absolute; right: 12px; top: 12px;
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--navy-100); color: var(--navy-600);
}
.stat.accent-gold  .spark { background: var(--gold-100);  color: var(--gold-600); }
.stat.accent-green .spark { background: var(--green-100); color: var(--green-600); }
.stat.accent-red   .spark { background: var(--red-100);   color: var(--red-600); }
.stat.accent-red   .val   { color: var(--red-600); }
.stat.accent-green .val   { color: var(--green-600); }

/* Dark mode needs its own tints: the light ones sit too close to the surface. */
html[data-theme="dark"] .stat .spark              { background: rgba(120, 155, 215, .16); color: #a9c1ea; }
html[data-theme="dark"] .stat.accent-gold  .spark { background: rgba(237, 174, 65, .16);  color: var(--gold-400); }
html[data-theme="dark"] .stat.accent-green .spark { background: rgba(34, 197, 94, .16);   color: #5ee29a; }
html[data-theme="dark"] .stat.accent-red   .spark { background: rgba(244, 63, 94, .16);   color: #ff8fa8; }
html[data-theme="dark"] .stat.accent-red   .val   { color: #ff8fa8; }
html[data-theme="dark"] .stat.accent-green .val   { color: #5ee29a; }
html[data-theme="dark"] .bar                      { background: rgba(255, 255, 255, .08); }

/* ----------------------------------------------------------------- badges */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 99px;
    font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
    white-space: nowrap; line-height: 1.5;
}
.badge-navy  { background: var(--navy-100);  color: var(--navy-700); }
.badge-gold  { background: var(--gold-100);  color: var(--gold-600); }
.badge-green { background: var(--green-100); color: var(--green-600); }
.badge-red   { background: var(--red-100);   color: var(--red-600); }
.badge-slate { background: var(--slate-100); color: var(--slate-600); }
html[data-theme="dark"] .badge-navy  { color: #a9c1ea; }
html[data-theme="dark"] .badge-green { color: #5ee29a; }
html[data-theme="dark"] .badge-red   { color: #ff8fa8; }
html[data-theme="dark"] .badge-gold  { color: var(--gold-400); }
html[data-theme="dark"] .badge-slate { color: #a7b6d0; }

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 99px;
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 12.5px; color: var(--text-soft);
}

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 16px; min-height: 42px;
    border-radius: 10px; border: 1px solid transparent;
    font-size: 14.5px; font-weight: 600; font-family: inherit;
    cursor: pointer; white-space: nowrap;
    transition: background var(--fast), border-color var(--fast), color var(--fast), transform var(--fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--navy-700); color: #fff; }
.btn-primary:hover { background: var(--navy-600); color: #fff; }

.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-400); color: var(--navy-900); }

.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-hover); border-color: var(--navy-400); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger { background: var(--red-500); color: #fff; }
.btn-danger:hover { background: var(--red-600); color: #fff; }

.btn-success { background: var(--green-500); color: #fff; }
.btn-success:hover { background: var(--green-600); color: #fff; }

.btn-sm { padding: 6px 11px; min-height: 34px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-height: 36px; width: 36px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------------ forms */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label {
    display: block; font-size: 13.5px; font-weight: 600;
    margin-bottom: 6px; color: var(--text);
}
.label .req { color: var(--red-500); }
.hint {
    font-size: 12.5px; color: var(--text-soft); margin-top: 5px; line-height: 1.5;
}
.hint-dz {
    display: flex; gap: 6px; align-items: flex-start;
    font-size: 13px; color: var(--text-soft); margin-top: 6px;
    direction: rtl; text-align: right;
}
.hint-dz.ltr { direction: ltr; text-align: left; }

.input, .select, .textarea {
    width: 100%;
    padding: 11px 13px;
    min-height: 44px;
    font-family: inherit; font-size: 15px; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    transition: border-color var(--fast), box-shadow var(--fast);
    appearance: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--navy-500);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-500) 18%, transparent);
}
.input.err, .select.err, .textarea.err { border-color: var(--red-500); }
.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2356637a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
html[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a7b6d0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.err-msg { color: var(--red-500); font-size: 12.5px; margin-top: 5px; font-weight: 500; }

.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
/* Un champ ne doit jamais élargir la page sur un téléphone (option longue dans un
   select, mot très long…) : les colonnes peuvent rétrécir et le champ est borné. */
.form-grid > *, .grid > *, .dash-split > * { min-width: 0; }
.input, .select, .textarea { max-width: 100%; }
/* Un texte sans espace (chemin de fichier, lien, n° de suivi) doit se couper au
   lieu d'élargir la page sur un téléphone. */
code, kbd, samp { overflow-wrap: anywhere; }
pre { max-width: 100%; overflow-x: auto; }
.toast { max-width: 100%; overflow-wrap: anywhere; }

/* segmented radio / choice buttons — big tap targets on mobile */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 15px; min-height: 42px;
    border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--surface); color: var(--text-soft);
    font-size: 14px; font-weight: 550; cursor: pointer;
    transition: all var(--fast);
}
.choice input:checked + span {
    background: var(--navy-700); border-color: var(--navy-700); color: #fff;
}
.choice input:focus-visible + span { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.choice.yes input:checked + span { background: var(--green-500); border-color: var(--green-500); }
.choice.no  input:checked + span { background: var(--slate-600); border-color: var(--slate-600); }
.choice.warn input:checked + span { background: var(--gold-500); border-color: var(--gold-500); color: var(--navy-900); }
.choice.bad input:checked + span { background: var(--red-500); border-color: var(--red-500); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track {
    width: 44px; height: 26px; border-radius: 99px; background: var(--border-strong);
    position: relative; transition: background var(--fast); flex: 0 0 auto;
}
.switch .track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%; background: #fff;
    transition: transform var(--fast); box-shadow: var(--shadow-xs);
}
.switch input:checked + .track { background: var(--green-500); }
.switch input:checked + .track::after { transform: translateX(18px); }

.checkbox { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: 14.5px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 10px 18px; margin: 8px 0; }
.checkbox input {
    width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto;
    accent-color: var(--navy-700); cursor: pointer;
}

/* number stepper — comfortable on a phone */
.stepper { display: flex; align-items: stretch; max-width: 190px; }
.stepper button {
    width: 44px; min-height: 44px; border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--text); font-size: 20px; line-height: 1;
    cursor: pointer; font-family: inherit;
}
.stepper button:first-child { border-radius: 10px 0 0 10px; }
.stepper button:last-child { border-radius: 0 10px 10px 0; }
.stepper button:hover { background: var(--surface-hover); }
.stepper input {
    width: 100%; min-width: 56px; text-align: center;
    border: 1px solid var(--border-strong); border-left: 0; border-right: 0;
    background: var(--surface); color: var(--text);
    font-size: 16px; font-weight: 600; font-family: inherit;
    -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy-500) 18%, transparent); position: relative; z-index: 1; }

/* ----------------------------------------------------------------- tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.tbl th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--text-mute); font-weight: 700;
    padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
    background: var(--surface-2);
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-hover); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl th.num { text-align: right; }
table.tbl .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ------------------------------------------------------------- list items */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--border); }

.item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 13px 16px;
    transition: background var(--fast);
    color: var(--text);
}
.item:hover { background: var(--surface-hover); color: var(--text); }
.item .body { min-width: 0; flex: 1; }
.item .t { font-weight: 600; font-size: 14.5px; line-height: 1.4; color: var(--text); }
.item .m { font-size: 12.5px; color: var(--text-soft); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.item .end { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* task row */
.task {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 13px 14px;
    border-left: 3px solid transparent;
}
.task.p-high { border-left-color: var(--red-500); }
.task.p-normal { border-left-color: var(--navy-500); }
.task.p-low { border-left-color: var(--border-strong); }
.task.done .tt { text-decoration: line-through; color: var(--text-mute); }
/* Completing a task is the most-used action on a phone: keep it a big target. */
.task .tick {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
    border: 2px solid var(--border-strong); background: var(--surface);
    cursor: pointer; display: grid; place-items: center; color: transparent;
    transition: all var(--fast); margin-top: -2px; padding: 0;
}
.task .tick:hover { border-color: var(--green-500); color: var(--green-500); }
.task.done .tick { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.task .tt { font-weight: 600; font-size: 14.5px; line-height: 1.4; }
.task .meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 5px; font-size: 12.5px; color: var(--text-soft); }
.task .note { font-size: 13px; color: var(--text-soft); margin-top: 5px; }
.task .end { margin-left: auto; display: flex; gap: 5px; align-items: center; flex-shrink: 0; }

/* ------------------------------------------------------- install (PWA) */
.install-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 14px;
    border: 1px solid color-mix(in srgb, var(--gold-500) 45%, transparent);
    background: var(--gold-100); border-radius: var(--r);
    font-size: 14px;
}
.install-bar .ib-icon { font-size: 20px; line-height: 1; flex: 0 0 auto; }
.install-bar .ib-txt { flex: 1; min-width: 0; font-weight: 600; color: var(--gold-600); }
html[data-theme="dark"] .install-bar .ib-txt { color: var(--gold-400); }
.install-bar .ib-close {
    flex: 0 0 auto; width: 30px; height: 30px;
    border: 0; background: transparent; cursor: pointer;
    font-size: 22px; line-height: 1; color: var(--text-soft); border-radius: 8px;
}
.install-bar .ib-close:hover { background: rgba(0, 0, 0, .06); color: var(--text); }

@media (max-width: 420px) {
    .install-bar { flex-wrap: wrap; }
    .install-bar .ib-txt { flex: 1 1 auto; }
    .install-bar .btn { flex: 1 1 100%; order: 3; }
}

/* --------------------------------------------------------- stock upload */
/* Gros bouton unique : le responsable stock utilise surtout son téléphone. */
.upload-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; text-align: center;
    min-height: 148px; padding: 22px 16px;
    border: 2px dashed var(--border-strong); border-radius: var(--r-lg);
    background: var(--surface-2); cursor: pointer;
    transition: border-color var(--fast), background var(--fast);
    position: relative;
}
.upload-drop:hover, .upload-drop:focus-within {
    border-color: var(--gold-500); background: var(--gold-100);
}
.upload-drop .ic-wrap {
    width: 52px; height: 52px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--navy-700); color: #fff;
}
.upload-drop .ic-wrap .ic { width: 26px; height: 26px; }
.upload-drop .t { font-weight: 700; font-size: 16px; color: var(--text); }
.upload-drop .s { font-size: 13px; color: var(--text-soft); }
.upload-drop input[type="file"] {
    position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer;
}

.picked-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.picked {
    font-size: 13px; padding: 8px 11px; border-radius: 9px;
    background: var(--green-100); color: var(--green-600);
    border: 1px solid color-mix(in srgb, var(--green-500) 30%, transparent);
    word-break: break-word;
}
html[data-theme="dark"] .picked { color: #5ee29a; }

.btn-lg { min-height: 52px; font-size: 16px; border-radius: 12px; }

/* aperçu des pages téléversées */
.page-card {
    border: 1px solid var(--border); border-radius: var(--r);
    overflow: hidden; background: var(--surface-2);
}
.page-card img { width: 100%; height: 190px; object-fit: cover; display: block; }
.page-card .page-pdf {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; height: 190px; color: var(--navy-600); font-weight: 700; font-size: 14px;
}
html[data-theme="dark"] .page-card .page-pdf { color: #a9c1ea; }
.page-card .page-pdf .ic { width: 38px; height: 38px; }
.page-meta {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--text-soft);
    background: var(--surface); border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------- avatar */
.av {
    width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center;
    font-size: 13px; font-weight: 700; color: #fff;
    background: var(--navy-600); letter-spacing: -.02em;
}
.av-sm { width: 28px; height: 28px; font-size: 11px; }
.av-lg { width: 48px; height: 48px; font-size: 16px; }

/* ------------------------------------------------------------ empty state */
.empty { text-align: center; padding: 44px 20px; }
.empty .emo { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.empty .t { font-weight: 650; font-size: 16px; margin-bottom: 4px; }
.empty .s { color: var(--text-soft); font-size: 14px; max-width: 380px; margin: 0 auto 14px; }

/* ---------------------------------------------------------------- alerts */
.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--r);
    font-size: 14px; border: 1px solid transparent; margin-bottom: 14px;
}
.alert-success { background: var(--green-100); border-color: color-mix(in srgb, var(--green-500) 35%, transparent); color: var(--green-600); }
.alert-error   { background: var(--red-100);   border-color: color-mix(in srgb, var(--red-500) 35%, transparent);   color: var(--red-600); }
.alert-info    { background: var(--navy-100);  border-color: color-mix(in srgb, var(--navy-500) 30%, transparent);  color: var(--navy-700); }
.alert-warn    { background: var(--gold-100);  border-color: color-mix(in srgb, var(--gold-500) 45%, transparent);  color: var(--gold-600); }
html[data-theme="dark"] .alert-success { color: #6ee7a4; }
html[data-theme="dark"] .alert-error   { color: #ff9db2; }
html[data-theme="dark"] .alert-info    { color: #bcd0ee; }
html[data-theme="dark"] .alert-warn    { color: var(--gold-400); }

.toasts {
    position: fixed; left: 12px; right: 12px; bottom: 12px;
    z-index: 200; display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--surface); border: 1px solid var(--border);
    border-left: 4px solid var(--navy-600);
    border-radius: var(--r); padding: 12px 14px;
    box-shadow: var(--shadow-lg); font-size: 14px;
    display: flex; gap: 9px; align-items: flex-start;
    pointer-events: auto;
    animation: toastIn .22s ease;
}
.toast.success { border-left-color: var(--green-500); }
.toast.error { border-left-color: var(--red-500); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------- help box */
.help {
    border: 1px solid color-mix(in srgb, var(--gold-500) 40%, transparent);
    background: var(--gold-100);
    border-radius: var(--r);
    margin-bottom: 16px;
    overflow: hidden;
}
.help > summary {
    padding: 11px 14px; cursor: pointer; font-weight: 650; font-size: 14px;
    color: var(--gold-600); list-style: none;
    display: flex; align-items: center; gap: 8px;
}
html[data-theme="dark"] .help > summary { color: var(--gold-400); }
.help > summary::-webkit-details-marker { display: none; }
.help > summary::after {
    content: "▾"; margin-left: auto; transition: transform var(--fast); font-size: 12px;
}
.help[open] > summary::after { transform: rotate(180deg); }
.help .help-body { padding: 0 14px 14px; font-size: 14px; color: var(--text); line-height: 1.7; }
.help .help-body ol, .help .help-body ul { margin: 6px 0; padding-inline-start: 20px; }
.help .help-body li { margin-bottom: 5px; }

.rtl { direction: rtl; text-align: right; }
.rtl ol, .rtl ul { padding-inline-start: 0; padding-inline-end: 20px; }

.help-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--gold-600); font-weight: 600;
    background: var(--gold-100); border: 1px solid color-mix(in srgb, var(--gold-500) 40%, transparent);
    padding: 6px 11px; border-radius: 99px; cursor: pointer; font-family: inherit;
}
.help-btn:hover { background: var(--gold-400); color: var(--navy-900); }

/* ---------------------------------------------------------------- modals */
.modal {
    position: fixed; inset: 0; z-index: 120;
    display: none; align-items: flex-end; justify-content: center;
    background: rgba(9, 16, 30, .55); backdrop-filter: blur(3px);
    padding: 0;
}
.modal.open { display: flex; }
.modal-box {
    background: var(--surface);
    width: 100%; max-width: 620px;
    max-height: 92vh; overflow-y: auto;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-lg);
    animation: sheetUp .22s cubic-bezier(.32, .72, 0, 1);
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; gap: 10px;
    padding: 15px 16px; border-bottom: 1px solid var(--border);
    background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.modal-head h3 { font-size: 16px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px; }
.modal-foot {
    position: sticky; bottom: 0;
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 16px; border-top: 1px solid var(--border);
    background: var(--surface);
}
.modal-foot .btn { flex: 1; }

/* ------------------------------------------------------------------- tabs */
.tabs {
    display: flex; gap: 4px; overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: 10px 14px; font-size: 14px; font-weight: 600;
    color: var(--text-soft); white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    display: flex; align-items: center; gap: 7px;
    background: none; border-top: 0; border-left: 0; border-right: 0;
    cursor: pointer; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--navy-700); border-bottom-color: var(--gold-500); }
html[data-theme="dark"] .tab.active { color: var(--gold-400); }
.tab .n {
    background: var(--slate-100); color: var(--text-soft);
    font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
}
.tab.active .n { background: var(--gold-500); color: var(--navy-900); }

/* --------------------------------------------------------------- filters */
.filters {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
    margin-bottom: 14px;
}
.filters .f { flex: 1 1 150px; min-width: 0; }
.filters .f .label { font-size: 12px; margin-bottom: 4px; color: var(--text-soft); }
.filters .input, .filters .select { min-height: 40px; padding: 8px 12px; font-size: 14px; }

/* --------------------------------------------------------------- progress */
.bar { height: 7px; border-radius: 99px; background: var(--slate-100); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--gold-500); transition: width .4s ease; }
.bar.ok > i { background: var(--green-500); }
.bar.navy > i { background: var(--navy-600); }

.ring { display: grid; place-items: center; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .rv { position: absolute; font-size: 13px; font-weight: 700; }

/* ------------------------------------------------------------ definition */
.dl { display: grid; grid-template-columns: 1fr; gap: 10px; }
.dl .dt { font-size: 12px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.dl .dd { font-size: 14.5px; margin-top: 2px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-soft); }
.kv .v { font-weight: 650; text-align: right; }

/* ------------------------------------------------------------- login page */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1fr;
    background: var(--bg);
}
.auth-side {
    background: linear-gradient(160deg, var(--navy-700) 0%, var(--navy-900) 100%);
    color: #fff; padding: 30px 24px; display: none;
    position: relative; overflow: hidden;
}
.auth-side::after {
    content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%;
    background: radial-gradient(circle, rgba(237, 174, 65, .22), transparent 70%);
    right: -90px; bottom: -90px;
}
.auth-main { display: flex; align-items: center; justify-content: center; padding: 28px 18px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo img { width: 116px; margin: 0 auto 10px; }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--text-soft); font-size: 14px; margin-top: 5px; margin-bottom: 22px; }
.auth-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 22px; box-shadow: var(--shadow); }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--text-mute); }

/* ---------------------------------------------------------- guide layout */
.guide-card {
    border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface); overflow: hidden; margin-bottom: 12px;
    box-shadow: var(--shadow-xs);
}
.guide-card > summary {
    padding: 15px 16px; cursor: pointer; list-style: none;
    display: flex; align-items: center; gap: 11px;
    font-weight: 650; font-size: 15.5px;
}
.guide-card > summary::-webkit-details-marker { display: none; }
.guide-card > summary .emo { font-size: 21px; line-height: 1; }
.guide-card > summary::after { content: "▾"; margin-left: auto; color: var(--text-mute); transition: transform var(--fast); }
.guide-card[open] > summary::after { transform: rotate(180deg); }
.guide-card[open] > summary { border-bottom: 1px solid var(--border); }
.guide-body { padding: 16px; font-size: 15px; line-height: 1.85; }
.guide-body.rtl { direction: rtl; text-align: right; }
.guide-body ol, .guide-body ul { margin: 8px 0; }
.guide-body li { margin-bottom: 7px; }
.guide-body .ex {
    background: var(--surface-2); border: 1px dashed var(--border-strong);
    border-radius: var(--r); padding: 11px 13px; margin: 10px 0; font-size: 14px;
}
.guide-body .ex.good { border-color: color-mix(in srgb, var(--green-500) 45%, transparent); background: var(--green-100); }
.guide-body .ex.bad  { border-color: color-mix(in srgb, var(--red-500) 45%, transparent);  background: var(--red-100); }

/* ------------------------------------------------------------- onboarding */
.tour { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(9, 16, 30, .72); padding: 16px; backdrop-filter: blur(4px); }
.tour-box { background: var(--surface); border-radius: var(--r-xl); max-width: 460px; width: 100%; padding: 26px 22px; box-shadow: var(--shadow-lg); text-align: center; }
.tour-box .emo { font-size: 44px; line-height: 1; }
.tour-box h2 { font-size: 20px; margin: 12px 0 8px; }
.tour-box p { color: var(--text-soft); font-size: 14.5px; }
.tour-dots { display: flex; gap: 6px; justify-content: center; margin: 18px 0; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); transition: all var(--fast); }
.tour-dots i.on { background: var(--gold-500); width: 20px; border-radius: 99px; }

/* --------------------------------------------------------------- utility */
.muted { color: var(--text-soft); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 14px; } .mb-3 { margin-bottom: 20px; }
.flex { display: flex; gap: 10px; }
.flex-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.flex-center { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.tabnum { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.hide-mobile { display: none; }

/* ===================================================== responsive: ≥480px */
@media (min-width: 480px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .modal { align-items: center; padding: 20px; }
    .modal-box { border-radius: var(--r-xl); }
    .modal-head { border-radius: var(--r-xl) var(--r-xl) 0 0; }
    .modal-foot .btn { flex: 0 0 auto; }
    .toasts { left: auto; right: 16px; bottom: 16px; max-width: 380px; }
}

/* ===================================================== responsive: ≥768px */
@media (min-width: 768px) {
    .page { padding: 22px 22px 60px; }
    .page-head .ttl { font-size: 25px; }
    .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
    .g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
    .hide-mobile { display: initial; }
    .auth { grid-template-columns: 1fr; }
    .card-pad { padding: 20px; }
}

/* ==================================================== responsive: ≥1024px */
@media (min-width: 1024px) {
    .sidebar { transform: none; box-shadow: none; border-right: 1px solid rgba(255, 255, 255, .06); }
    .side-close { display: none; }
    .scrim { display: none; }
    .main { margin-left: var(--side-w); }
    .nav-toggle { display: none; }
    .topbar { padding: 0 22px; }
    .topbar .brand-mini { display: none; }
    .g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .dash-split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
    .auth { grid-template-columns: 1.05fr 1fr; }
    .auth-side { display: flex; flex-direction: column; justify-content: center; padding: 48px; }
    table.tbl { min-width: 0; }
    .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ==================================================== responsive: ≥1280px */
@media (min-width: 1280px) {
    .page { padding: 26px 30px 60px; }
    .dash-split { gap: 20px; }
}

/* ================================================================ Vidéos ===
   Google Drive, évaluations indépendantes, comparaison. Uniquement des
   ajouts, avec les jetons de couleur existants (clair + sombre). */
.vid-file { overflow-wrap: anywhere; }

.eval-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.eval-dot {
    font-size: 12px; padding: 3px 9px; border-radius: 99px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
}
.eval-dot.ok { color: var(--green-600); border-color: color-mix(in srgb, var(--green-500) 35%, transparent); }
html[data-theme="dark"] .eval-dot.ok { color: #5ee29a; }

/* sélection Drive */
.drive-pick { display: grid; gap: 8px; }
.drive-link > summary { cursor: pointer; padding: 4px 0; list-style: none; }
.drive-link > summary::-webkit-details-marker { display: none; }
.drive-link-row { display: flex; gap: 8px; margin-top: 6px; }
.drive-link-row .input { flex: 1; min-width: 0; }
.drive-status { margin-top: 8px; }
.drive-file {
    display: flex; gap: 12px; align-items: center; margin-top: 10px;
    padding: 12px; border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--green-500) 40%, transparent);
    background: var(--green-100);
}
.drive-file-ic {
    flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
    background: var(--surface); color: var(--navy-700);
}
.drive-file-meta { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.drive-ref code { font-size: 11px; }
html[data-theme="dark"] .drive-file { background: rgba(34, 197, 94, .1); }
html[data-theme="dark"] .drive-file-ic { color: #a9c1ea; }

/* barre de chargement entre deux pages (le clic répond tout de suite) */
.nav-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 400;
    background: var(--gold-500); border-radius: 0 3px 3px 0;
    animation: navProgress 5s ease-out forwards;
}
@keyframes navProgress { 0% { width: 0; } 12% { width: 45%; } 40% { width: 75%; } 100% { width: 94%; } }
@media (prefers-reduced-motion: reduce) { .nav-progress { animation: none; width: 40%; } }

/* mesure de vitesse (?perf=1, Admin) */
.perf-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 250;
    background: rgba(9, 16, 30, .92); color: #fff; font-size: 12px; line-height: 1.4;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); overflow-wrap: anywhere;
}
.perf-bar code { color: #ffd77a; font-size: 11px; }

/* Google Picker au-dessus de la fenêtre modale */
.picker-dialog-bg { z-index: 1000 !important; }
.picker-dialog { z-index: 1001 !important; }
/* Téléphone : Picker en plein écran (sinon il s'ouvre hors de l'écran, 1051 px de large) */
@media (max-width: 759px) {
    html.picker-open .picker-dialog {
        position: fixed !important; top: 0 !important; left: 0 !important;
        width: 100vw !important; height: 100vh !important; height: 100dvh !important;
        max-width: none !important; border: 0 !important; border-radius: 0 !important;
    }
    html.picker-open .picker-dialog-content,
    html.picker-open .picker-dialog-content iframe,
    html.picker-open .picker-dialog iframe {
        width: 100% !important; height: 100% !important;
    }
    html.picker-open .picker-dialog-title { display: none !important; }
}

/* formulaire d'évaluation */
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cat-in {
    display: flex; flex-direction: column; gap: 4px; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.cat-lbl { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.cat-val { display: flex; align-items: center; gap: 6px; }
.cat-val .input { min-height: 38px; padding: 6px 10px; max-width: 76px; text-align: center; }

/* cartes d'évaluation */
.eval-list { margin: 4px 0 0; padding-inline-start: 18px; font-size: 13.5px; }
.eval-list li { margin-bottom: 4px; unicode-bidi: plaintext; }
.eval-more { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.eval-more > summary { cursor: pointer; }
.cat-row { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.cat-row:last-child { border-bottom: 0; }
.eval-card .card-head h3 { white-space: nowrap; }
.eval-score { font-size: 13px; }
.note-body { font-size: 14px; margin-top: 3px; unicode-bidi: plaintext; overflow-wrap: anywhere; }

/* comparaison */
table.tbl.cmp-tbl { min-width: 0; }
table.tbl.cmp-tbl th, table.tbl.cmp-tbl td { padding: 9px 8px; }
table.tbl.cmp-tbl th { white-space: normal; }
.cmp-tbl .cmp-total td { background: var(--surface-2); }
.cmp-tbl tr.cmp-gap td { background: color-mix(in srgb, var(--red-500) 8%, transparent); }
.cmp-short { display: none; }
@media (max-width: 479px) {
    .cmp-tbl .cmp-long { display: none; }
    .cmp-tbl .cmp-short { display: inline; }
    table.tbl.cmp-tbl th, table.tbl.cmp-tbl td { padding: 8px 5px; font-size: 13px; }
    table.tbl.cmp-tbl th { font-size: 11px; letter-spacing: 0; text-transform: none; }
}
.cmp-box { border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.cmp-box.ok  { border-color: color-mix(in srgb, var(--green-500) 35%, transparent); }
.cmp-box.bad { border-color: color-mix(in srgb, var(--red-500) 35%, transparent); }

/* 🔔 notifications de l'appareil */
.push-state { display: flex; gap: 10px; align-items: flex-start; }
.push-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.push-txt { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.push-nudge .card-body { padding-top: 12px; padding-bottom: 12px; }
.device-list { list-style: none; margin: 6px 0 0; padding: 0; }
.device-list li { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.device-list li:last-child { border-bottom: 0; }
.spinner.spinner-sm { width: 14px; height: 14px; border-width: 2px; display: inline-block; vertical-align: -2px; }

/* 📊 réseaux sociaux */
.social-tbl .social-cap { min-width: 220px; max-width: 420px; unicode-bidi: plaintext; }
.social-summary { unicode-bidi: plaintext; line-height: 1.6; }
details.social-more > summary { cursor: pointer; list-style: none; }
details.social-more > summary::-webkit-details-marker { display: none; }
.social-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }

/* caption IA : lisible, copiable, dans la langue du texte */
.caption-text { min-height: 120px; line-height: 1.55; resize: vertical; unicode-bidi: plaintext; }
textarea.caption-text[readonly] { background: var(--surface-2, var(--surface)); cursor: text; }
#capSources .eval-list a { word-break: break-word; }
.link-video { margin-top: 4px; }
.secret-input { -webkit-text-security: disc; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.select.select-sm { min-height: 34px; padding: 4px 28px 4px 8px; font-size: 13px; max-width: 170px; }
.search-entry { display: block; width: 100%; height: 72px; border: 0; margin-top: 8px; border-radius: 8px; background: transparent; }

/* résumé que l'IA écrit pour le créateur de la vidéo */
.ai-tip {
    padding: 10px 12px; border-radius: var(--r);
    background: var(--navy-100);
    border-inline-start: 3px solid var(--gold-500);
}
html[data-theme="dark"] .ai-tip { background: rgba(120, 155, 215, .12); }
.ai-tip .small { unicode-bidi: plaintext; overflow-wrap: anywhere; }

/* analyse IA en cours */
.ai-status { display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 12px; border-radius: var(--r); background: var(--navy-100); }
html[data-theme="dark"] .ai-status { background: rgba(120, 155, 215, .12); }
.spinner {
    flex: none; width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--gold-500) 30%, transparent); border-top-color: var(--gold-500);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 768px) {
    .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    table.tbl.cmp-tbl th, table.tbl.cmp-tbl td { padding: 10px 14px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
    .sidebar, .topbar, .btn, .filters, .tabs { display: none !important; }
    .main { margin-left: 0; }
    .card { box-shadow: none; }
}

/* ===================================== 🧱 Structure des rapports (Admin) + rapport à modèle */
.rb-tag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    padding: 2px 7px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.rb-auto { background: var(--green-100); color: var(--green-600); }
.rb-emp  { background: var(--navy-100); color: var(--navy-700); }
.rb-opt  { background: var(--slate-100); color: var(--slate-600); }
.rb-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--text-soft); }
.rb-video { border: 1px solid var(--border); border-radius: var(--r); padding: 12px; margin-bottom: 12px; background: var(--surface-2); }
.rb-video:last-child { margin-bottom: 0; }
.rb-video-head { font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.rb-video-n { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: var(--navy-700); color: #fff;
    font-size: 12px; display: inline-grid; place-items: center; }
.rb-video .field:last-child { margin-bottom: 0; }
.rb-kv .k { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rb-kv .v { overflow-wrap: anywhere; }
.rb-long { padding: 10px 0; border-bottom: 1px solid var(--border); }
.rb-long:last-child { border-bottom: 0; }
.rb-list { display: grid; gap: 8px; }
.rb-list-row { display: flex; align-items: center; gap: 8px; }
.rb-list-n { flex: 0 0 auto; width: 24px; text-align: center; color: var(--text-mute); font-weight: 700; }
.rb-create { border: 1px dashed var(--border-strong); border-radius: var(--r); padding: 14px; }
.rb-tpl-item { flex-wrap: wrap; }
.rb-preview { border: 2px dashed var(--gold-500); border-radius: var(--r-lg); padding: 12px; }

.rb-sec.rb-off, .rb-field.rb-off { opacity: .55; }
.rb-sec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rb-sec-title { flex: 1 1 200px; font-weight: 700; }
.rb-sec-head .select { flex: 0 1 240px; }
.rb-sec-desc { margin-bottom: 10px; font-size: 13.5px; }
.rb-fields { display: grid; gap: 6px; min-height: 36px; padding: 4px; border-radius: var(--r); }
.rb-field { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border);
    border-radius: var(--r); background: var(--surface); }
.rb-field-main { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.rb-tools { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.rb-tools .btn { min-width: 34px; }
.rb-handle { cursor: grab; user-select: none; color: var(--text-mute); font-size: 18px; line-height: 1; padding: 4px 2px; touch-action: none; }
.rb-handle:active { cursor: grabbing; }
.rb-over { outline: 2px dashed var(--gold-500); outline-offset: 2px; }
.rb-dragging { opacity: .4; }
.rb-bar { position: sticky; bottom: 0; z-index: 30; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--shadow); }
@media (max-width: 599px) { .rb-bar .btn { flex: 1 1 100%; } .rb-handle { display: none; } }

/* ======================================================= 📚 Produits (1.5.0) */
.pk-search { position: relative; margin-bottom: 12px; }
.pk-search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 2px solid var(--border-strong);
    border-radius: var(--r-lg); padding: 6px 6px 6px 14px; box-shadow: var(--shadow-sm); }
.pk-search-box:focus-within { border-color: var(--gold-500); }
.pk-search-box > .ic { color: var(--text-mute); flex-shrink: 0; }
.pk-q { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; padding: 10px 0; outline: none; }
.pk-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.pk-sug { display: flex; gap: 10px; align-items: center; padding: 8px 12px; color: var(--text); }
.pk-sug + .pk-sug { border-top: 1px solid var(--border); }
.pk-sug:hover, .pk-sug.on { background: var(--surface-hover); color: var(--text); }
.pk-sug img, .pk-sug-ic { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; flex-shrink: 0;
    display: grid; place-items: center; font-size: 20px; }
.pk-sug-t { display: flex; flex-direction: column; min-width: 0; }
.pk-cats, .pk-status-row, .pk-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.pk-cats::-webkit-scrollbar, .pk-status-row::-webkit-scrollbar, .pk-nav::-webkit-scrollbar { display: none; }
.pk-cats .chip, .pk-status-row .chip, .pk-nav .chip { white-space: nowrap; color: var(--text); }
.chip.pk-on { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.chip.pk-on .muted { color: rgba(255, 255, 255, .7); }
.pk-nav { position: sticky; top: var(--topbar-h); z-index: 20; background: var(--bg); padding: 8px 0; margin-bottom: 8px; }
.pk-howto { margin: 0 0 10px; padding-left: 20px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.pk-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-xs); min-width: 0; }
.pk-card-img { display: grid; place-items: center; height: 170px; background: #fff; border-bottom: 1px solid var(--border); }
.pk-card-img img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 10px; }
.pk-noimg { font-size: 44px; opacity: .6; }
.pk-noimg.big { font-size: 72px; }
.pk-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.pk-card-top { display: flex; flex-wrap: wrap; gap: 4px; }
.pk-card-name { font-size: 16px; }
.pk-card-name a { color: var(--text); }
.pk-card-desc { margin: 0; color: var(--text-soft); }
.pk-card-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.pk-price { font-size: 18px; font-weight: 700; color: var(--navy-700); }
html[data-theme="dark"] .pk-price { color: var(--gold-400); }
.pk-hero { display: grid; grid-template-columns: 1fr; overflow: hidden; }
.pk-hero-img { background: #fff; display: grid; place-items: center; padding: 16px; min-height: 220px; position: relative; }
.pk-hero-img img { max-width: 100%; max-height: 300px; object-fit: contain; }
.pk-img-src { position: absolute; bottom: 6px; right: 10px; font-size: 11px; color: #8a94a6; }
.pk-hero-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pk-lead { font-size: 15.5px; margin: 0 0 8px; }
.pk-prices { display: grid; gap: 8px; }
.pk-var { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2); }
.pk-var-name { font-weight: 600; }
.pk-var-price { font-size: 20px; font-weight: 700; color: var(--navy-700); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
html[data-theme="dark"] .pk-var-price { color: var(--gold-400); }
.pk-var-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-soft); }
.pk-cost { color: var(--red-600); }
.pk-ul { margin: 0; padding-left: 18px; }
.pk-ul li + li { margin-top: 3px; }
.pk-ol { margin: 0; padding-left: 22px; }
.pk-ol li { padding: 5px 0; }
.pk-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pk-box { border-radius: var(--r); padding: 10px 12px; }
.pk-good { background: var(--green-100); }
.pk-other { background: var(--gold-100); }
.pk-args { display: grid; gap: 10px; }
.pk-arg { border-left: 3px solid var(--gold-500); padding: 6px 0 6px 12px; }
.pk-arg-phrase { font-size: 15.5px; margin-top: 3px; }
.pk-acc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; margin-bottom: 8px; }
.pk-acc { display: flex; gap: 10px; border: 1px solid var(--border); border-radius: var(--r); padding: 10px; min-width: 0; }
.pk-acc-img { width: 64px; height: 64px; flex-shrink: 0; display: grid; place-items: center; background: #fff; border-radius: 10px; overflow: hidden; font-size: 26px; }
.pk-acc-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pk-acc-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pk-pack { border: 1px dashed var(--border-strong); border-radius: var(--r); padding: 10px 12px; }
.pk-pack + .pk-pack { margin-top: 10px; }
.pk-obj { padding: 12px 16px; }
.pk-obj summary { cursor: pointer; font-weight: 600; }
.pk-obj-a { margin-top: 8px; color: var(--text); }
.pk-specs { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 8px; }
.pk-spec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 9px 12px; }
.pk-spec + .pk-spec { border-top: 1px solid var(--border); }
.pk-spec-name { font-size: 12.5px; color: var(--text-soft); font-weight: 600; }
.pk-spec-val { overflow-wrap: anywhere; }
.pk-spec-check { background: var(--gold-100); }
.pk-spec-adv { color: var(--green-600); }
.pk-spec-say { color: var(--text-soft); font-style: italic; }
.pk-alt-list { display: grid; gap: 10px; }
.pk-alt { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 3px; }
.pk-row { align-items: center; }
.pk-row > input[type=checkbox] { width: 18px; height: 18px; flex-shrink: 0; }
.pk-thumb { width: 48px; height: 48px; flex-shrink: 0; display: grid; place-items: center; background: #fff; border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; font-size: 22px; }
.pk-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pk-thumb.big { width: 140px; height: 140px; font-size: 48px; }
.pk-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.pk-bulk .select { width: auto; min-height: 36px; padding: 6px 10px; }
.pk-rep-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: start; margin-bottom: 8px; }
.pk-rep-row > .btn { align-self: center; }
.pk-w-s { max-width: 90px; }
.pk-spec-edit, .pk-var-edit { border: 1px solid var(--border); border-radius: var(--r); padding: 10px; margin-bottom: 10px; display: grid; gap: 8px; }
.pk-spec-edit .form-grid, .pk-var-edit .form-grid { margin: 0; }
.pk-spec-edit > *, .pk-var-edit > *, .pk-rep-row > * { min-width: 0; }
.pk-spec-edit-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pk-spec-edit-top > :not(.btn) { flex: 1 1 170px; min-width: 0; width: auto; }
.pk-spec-edit-top > .btn { flex: 0 0 auto; margin-left: auto; }
.pk-img-edit { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.pk-img-edit > div:last-child { flex: 1 1 260px; min-width: 0; }
.pk-catrow { display: block; }
.pk-catrow summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pk-child { padding-left: 34px; }
@media (min-width: 768px) {
    .pk-hero { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
    .pk-hero-img { border-right: 1px solid var(--border); }
    .pk-spec { grid-template-columns: minmax(0, 0.35fr) minmax(0, 0.65fr); gap: 12px; }
    .pk-rep-row { grid-template-columns: minmax(0, 2fr) 90px minmax(0, 1fr) auto; }
    .pk-rep-row.pk-rep-3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) auto; }
    .pk-rep-row.pk-rep-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; }
}
@media (max-width: 767px) {
    .pk-rep-row > :not(.btn) { grid-column: 1; }
    .pk-rep-row > .btn { grid-column: 2; grid-row: 1; }
    .pk-q { font-size: 16px; }
    .pk-search-box .btn { padding-left: 12px; padding-right: 12px; }
}
.pk-btn-wrap { white-space: normal; text-align: left; height: auto; max-width: 100%; }

/* ------------------------------------------ 📚 Produits 1.5.1 : fiche vente en darija */
.pk-noimg { display: grid; place-items: center; width: 100%; height: 100%; min-height: 60px; padding: 8px;
    background: var(--surface-2); color: var(--text-mute); font-size: 12px; font-weight: 600; text-align: center;
    line-height: 1.3; opacity: 1; border-radius: inherit; }
.pk-noimg.big { font-size: 14px; min-height: 200px; }
.pk-thumb .pk-noimg { min-height: 0; padding: 2px; font-size: 8px; }
.pk-acc-img .pk-noimg { min-height: 0; font-size: 10px; }
.pk-sug-ic { background: var(--surface-2); }
.pk-noprice { display: inline-block; font-size: 13px; font-weight: 600; color: var(--gold-600);
    background: var(--gold-100); border-radius: 99px; padding: 2px 10px; }
.pk-dz { direction: rtl; text-align: right; font-size: 15.5px; line-height: 1.75; }
.pk-dz .card-head { flex-direction: row; }
.pk-dz .card-head h2 { font-size: 17px; }
.pk-dz .pk-ul { padding-left: 0; padding-right: 18px; }
.pk-dz .pk-ol { padding-left: 0; padding-right: 24px; }
.pk-dz .pk-arg { border-left: 0; border-right: 3px solid var(--gold-500); padding: 6px 12px 6px 0; }
.pk-dz-h { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; color: var(--text); }
.pk-hero-body .pk-dz { font-size: 15.5px; }
.pk-hero-body .pk-dz .pk-lead { margin: 0; }
.pk-wins { margin: 0; padding: 12px 16px 14px; padding-right: 34px; display: grid; gap: 8px; }
.pk-wins li { padding-right: 2px; }
.pk-wins li::marker { font-weight: 700; color: var(--gold-600); }
.pk-feat { font-weight: 700; color: var(--navy-700); background: var(--navy-50); border-radius: 6px; padding: 1px 6px; }
html[data-theme="dark"] .pk-feat { color: #a9c1ea; }
.pk-arrow { color: var(--gold-600); font-weight: 700; margin: 0 2px; }
.pk-pitch { font-size: 17px; font-weight: 600; background: var(--gold-100); border-radius: var(--r); padding: 12px 14px; }
.pk-no { background: var(--red-100); }
.pk-acc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pk-dz .pk-acc-body { text-align: right; }
.pk-dz .pk-obj summary { font-size: 15.5px; }
.pk-dz .pk-chips { justify-content: flex-start; }
.pk-dz .chip { direction: ltr; }
