/* ==========================================================================
   Procédures — feuille de style unique
   Design coloré et moderne, mode clair / sombre automatique
   (prefers-color-scheme), animations légères (désactivées si
   prefers-reduced-motion). Aucune ressource externe : polices système,
   icônes SVG inline.
   ========================================================================== */

/* ---------- 1. Variables de thème ---------- */
:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f1f2f9;
    --surface-3: #e8eaf5;
    --border: #e1e4f0;
    --text: #151935;
    --text-muted: #5a6180;

    --accent: #5046e5;
    --accent-strong: #4338ca;
    --accent-2: #7c3aed;
    --accent-3: #db2777;
    --accent-soft: #ecebff;
    --accent-text: #ffffff;
    --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #db2777 100%);
    --grad-btn: linear-gradient(135deg, #5046e5 0%, #7c3aed 100%);

    --hero-1: #3730a3;
    --hero-2: #6d28d9;
    --hero-3: #be185d;

    --danger: #d92d43;
    --danger-soft: #fde8eb;
    --success: #0f8a5f;
    --success-soft: #e3f7ee;
    --error-soft: #fde8eb;

    --pdf: #dc2626;
    --pdf-soft: #fee2e2;
    --doc: #2563eb;
    --doc-soft: #dbeafe;

    --focus: #5046e5;
    --radius-s: 10px;
    --radius: 16px;
    --radius-l: 22px;
    --shadow-1: 0 1px 2px rgba(21, 25, 53, .05), 0 2px 6px rgba(21, 25, 53, .05);
    --shadow-2: 0 6px 18px rgba(21, 25, 53, .08), 0 2px 6px rgba(21, 25, 53, .06);
    --shadow-3: 0 18px 40px rgba(49, 46, 129, .18), 0 4px 12px rgba(21, 25, 53, .08);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b0e1d;
        --surface: #141831;
        --surface-2: #1b2040;
        --surface-3: #242a4f;
        --border: #2a3058;
        --text: #eceefb;
        --text-muted: #a3a9c9;

        --accent: #8b85ff;
        --accent-strong: #a5a0ff;
        --accent-2: #a78bfa;
        --accent-3: #f472b6;
        --accent-soft: #262a5c;
        --accent-text: #0b0e1d;
        --grad-btn: linear-gradient(135deg, #8b85ff 0%, #b18cff 100%);

        --hero-1: #1e1b4b;
        --hero-2: #3b0f74;
        --hero-3: #6b0f3e;

        --danger: #ff6b81;
        --danger-soft: #3a1622;
        --success: #4fd6a0;
        --success-soft: #11372a;
        --error-soft: #3a1622;

        --pdf: #ff7a7a;
        --pdf-soft: #3d1a20;
        --doc: #7aa7ff;
        --doc-soft: #1a2950;

        --focus: #a5a0ff;
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow-2: 0 8px 22px rgba(0, 0, 0, .35);
        --shadow-3: 0 20px 44px rgba(0, 0, 0, .5);
    }
}

/* ---------- 2. Couleurs des catégories (palette fermée) ----------
   --c   : teinte vive (pastille, liseré de carte)
   --cbg : fond du badge   --cfg : texte du badge (contraste ≥ 4.5:1)    */
.cat--indigo    { --c: #6366f1; --cbg: #e0e7ff; --cfg: #3730a3; }
.cat--violet    { --c: #8b5cf6; --cbg: #ede9fe; --cfg: #5b21b6; }
.cat--rose      { --c: #ec4899; --cbg: #fce7f3; --cfg: #9d174d; }
.cat--rouge     { --c: #ef4444; --cbg: #fee2e2; --cfg: #991b1b; }
.cat--orange    { --c: #f97316; --cbg: #ffedd5; --cfg: #9a3412; }
.cat--ambre     { --c: #f59e0b; --cbg: #fef3c7; --cfg: #854d0e; }
.cat--vert      { --c: #22c55e; --cbg: #dcfce7; --cfg: #166534; }
.cat--turquoise { --c: #14b8a6; --cbg: #ccfbf1; --cfg: #115e59; }
.cat--bleu      { --c: #0ea5e9; --cbg: #e0f2fe; --cfg: #075985; }
.cat--ardoise   { --c: #64748b; --cbg: #e2e8f0; --cfg: #334155; }
.cat--none      { --c: #9aa1b9; --cbg: #eceef5; --cfg: #4b5270; }

@media (prefers-color-scheme: dark) {
    .cat--indigo    { --cbg: rgba(99, 102, 241, .22);  --cfg: #c7d2fe; }
    .cat--violet    { --cbg: rgba(139, 92, 246, .22);  --cfg: #ddd6fe; }
    .cat--rose      { --cbg: rgba(236, 72, 153, .22);  --cfg: #fbcfe8; }
    .cat--rouge     { --cbg: rgba(239, 68, 68, .22);   --cfg: #fecaca; }
    .cat--orange    { --cbg: rgba(249, 115, 22, .22);  --cfg: #fed7aa; }
    .cat--ambre     { --cbg: rgba(245, 158, 11, .22);  --cfg: #fde68a; }
    .cat--vert      { --cbg: rgba(34, 197, 94, .2);    --cfg: #bbf7d0; }
    .cat--turquoise { --cbg: rgba(20, 184, 166, .22);  --cfg: #99f6e4; }
    .cat--bleu      { --cbg: rgba(14, 165, 233, .22);  --cfg: #bae6fd; }
    .cat--ardoise   { --cbg: rgba(100, 116, 139, .3);  --cfg: #e2e8f0; }
    .cat--none      { --c: #6b7393; --cbg: rgba(154, 161, 185, .16); --cfg: #cfd3e6; }
}

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; }
a { color: var(--accent); }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.muted { color: var(--text-muted); font-size: .9rem; }

/* Éléments dépendant de JavaScript (classe posée par app.js sur <html>) */
.no-js .js-only { display: none !important; }
.js .no-js-only { display: none !important; }

.icon {
    width: 1.15em; height: 1.15em;
    flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px 40px;
    flex: 1;
}

/* ---------- 4. En-tête (hero) ---------- */
.hero {
    position: relative;
    color: #fff;
    background:
        radial-gradient(1200px 400px at 10% -10%, rgba(255, 255, 255, .18), transparent 60%),
        radial-gradient(800px 380px at 95% 0%, rgba(244, 114, 182, .35), transparent 60%),
        linear-gradient(135deg, var(--hero-1) 0%, var(--hero-2) 55%, var(--hero-3) 100%);
    padding-bottom: 72px;
    margin-bottom: -44px;
    overflow: hidden;
}
.hero::after { /* légère texture de points */
    content: "";
    position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .6), transparent 85%);
    pointer-events: none;
}
.hero__inner {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 24px 0;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -.01em;
}
.brand__logo {
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.brand__logo svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.topbar__actions form { margin: 0; }
.admin-badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .8rem; font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(16, 185, 129, .22);
    box-shadow: inset 0 0 0 1px rgba(167, 243, 208, .45);
    color: #ecfdf5;
}

.hero__text { padding: 44px 0 22px; max-width: 760px; }
.hero__title {
    margin: 0 0 10px;
    font-size: clamp(1.8rem, 4.2vw, 2.9rem);
    font-weight: 800;
    letter-spacing: -.025em;
}
.hero__tagline { margin: 0; font-size: clamp(1rem, 1.6vw, 1.15rem); color: rgba(255, 255, 255, .86); }

.hero-search {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 640px;
}
.hero-search > .icon {
    position: absolute; left: 18px;
    width: 20px; height: 20px;
    color: #6b7193;
    pointer-events: none;
}
.hero-search input {
    width: 100%;
    font: inherit;
    font-size: 1.05rem;
    padding: 16px 52px 16px 50px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #151935;
    box-shadow: 0 10px 30px rgba(17, 12, 60, .28);
    transition: box-shadow .2s var(--ease);
}
.hero-search input::placeholder { color: #7a809e; }
.hero-search input:focus { outline: none; box-shadow: 0 10px 30px rgba(17, 12, 60, .28), 0 0 0 4px rgba(255, 255, 255, .55); }
.hero-search__kbd {
    position: absolute; right: 16px;
    font: 600 .8rem var(--font);
    color: #6b7193;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #d9dcea;
    background: #f5f6fb;
}
.hero__stats { margin: 16px 0 0; font-size: .92rem; color: rgba(255, 255, 255, .82); }
.hero__stats strong { color: #fff; }

/* ---------- 5. Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 650;
    font-size: .95rem;
    line-height: 1.2;
    padding: 11px 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s var(--ease), box-shadow .2s var(--ease), background-color .2s, color .2s, border-color .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--small { padding: 8px 13px; font-size: .88rem; border-radius: 10px; }
.btn--grow { flex: 1; }

.btn--primary {
    background: var(--grad-btn);
    color: var(--accent-text);
    box-shadow: 0 4px 14px rgba(80, 70, 229, .35);
}
.btn--primary:hover { box-shadow: 0 8px 22px rgba(80, 70, 229, .45); transform: translateY(-1px); }

.btn--light {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border-color: rgba(255, 255, 255, .35);
    backdrop-filter: blur(6px);
}
.btn--light:hover { background: rgba(255, 255, 255, .28); }

.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--ghost:disabled { cursor: default; opacity: .45; }
.btn--soft { background: var(--accent-soft); color: var(--accent-strong); }
.btn--soft:hover { background: var(--surface-3); }

.icon-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font: 600 .84rem var(--font);
    cursor: pointer;
    list-style: none;
    transition: background-color .2s, color .2s;
}
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--accent); }
.icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- 6. Champs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: .82rem; font-weight: 700; color: var(--text-muted); letter-spacing: .01em; }
.field__row { display: flex; gap: 8px; }
.field__row select { flex: 1; min-width: 0; }

input[type="text"],
input[type="password"],
select {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 10px 13px;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}
input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
select {
    cursor: pointer;
    appearance: none;
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.form-error {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--error-soft);
    color: var(--danger);
    font-weight: 600;
    font-size: .9rem;
}

/* Palette de couleurs (boutons radio) */
.palette { border: 0; margin: 0; padding: 0; min-width: 0; }
.palette legend { padding: 0; margin-bottom: 8px; }
.palette__swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.palette__input { position: absolute; opacity: 0; pointer-events: none; }
.palette__swatch {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--c);
    cursor: pointer;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
    transition: transform .15s var(--ease), box-shadow .15s;
}
.palette__swatch:hover { transform: scale(1.1); }
.palette__input:checked + .palette__swatch { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.palette__input:focus-visible + .palette__swatch { outline: 3px solid var(--focus); outline-offset: 4px; }

/* ---------- 7. Notifications ---------- */
.toasts {
    position: fixed;
    z-index: 50;
    right: 20px; bottom: 20px;
    display: flex; flex-direction: column; gap: 10px;
    width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 14px 14px 16px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-3);
    border-left: 5px solid var(--success);
    font-weight: 550;
    animation: toast-in .3s var(--ease);
}
.toast--error { border-left-color: var(--danger); }
.toast__text { flex: 1; }
.toast__close {
    border: 0; background: none; color: var(--text-muted);
    padding: 2px; border-radius: 6px; cursor: pointer;
}
.toast.is-leaving { animation: toast-out .25s var(--ease) forwards; }

/* ---------- 8. Administration ---------- */
.admin-grid {
    position: relative; z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 26px;
}
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-2);
    padding: 22px;
    min-width: 0;
}
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel__title {
    display: flex; align-items: center; gap: 10px;
    margin: 0 0 14px;
    font-size: 1.08rem;
}
.panel__head .panel__title { margin: 0; }
.panel__title .icon { color: var(--accent); width: 22px; height: 22px; }

.upload-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}
.field--wide { grid-column: 1 / -1; }
.dropzone {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px;
    padding: 22px 16px;
    border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--border));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background-color .2s, transform .2s var(--ease);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-dragover { transform: scale(1.01); }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone__input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone__icon .icon { width: 30px; height: 30px; color: var(--accent); }
.dropzone__text { color: var(--text); overflow-wrap: anywhere; }
.dropzone__hint { font-size: .82rem; color: var(--text-muted); }
.upload-progress {
    grid-column: 1 / -1;
    width: 100%; height: 8px;
    appearance: none;
    border: 0; border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
}
.upload-progress::-webkit-progress-bar { background: var(--surface-3); }
.upload-progress::-webkit-progress-value { background: var(--grad-btn); }
.upload-progress::-moz-progress-bar { background: var(--grad-btn); }
.upload-form .form-error { grid-column: 1 / -1; }

.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cat-row { padding: 6px 4px; border-radius: 12px; }
.cat-row:hover { background: var(--surface-2); }
.cat-row__main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cat-row__main form { margin: 0; }
.cat-row__count { font-size: .82rem; color: var(--text-muted); margin-right: auto; }
.cat-row__edit[open] { flex-basis: 100%; order: 5; }
.cat-row__edit[open] > summary { background: var(--surface-3); }
.cat-row__edit form, .newcat-inline form {
    margin-top: 8px;
    padding: 14px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.newcat-inline { margin-bottom: 12px; }
.newcat-inline > summary { list-style: none; width: max-content; }

/* ---------- 9. Badges ---------- */
.cat-badge {
    display: inline-flex; align-items: center; gap: 6px;
    max-width: 100%;
    padding: 4px 11px 4px 9px;
    border-radius: 999px;
    background: var(--cbg);
    color: var(--cfg);
    font-size: .8rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.cat-badge::before {
    content: "";
    width: 8px; height: 8px;
    flex: none;
    border-radius: 50%;
    background: var(--c);
}

/* ---------- 10. Filtres ---------- */
.list-section { position: relative; z-index: 2; }
.filters {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-2);
    padding: 16px 18px;
    margin-bottom: 22px;
}
.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: 650 .9rem var(--font);
    cursor: pointer;
    transition: transform .15s var(--ease), background-color .2s, border-color .2s, color .2s, box-shadow .2s;
}
.chip:hover { transform: translateY(-1px); border-color: var(--c, var(--accent)); }
.chip__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip__count {
    font-size: .76rem;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
}
.chip.is-active {
    background: var(--cbg, var(--accent-soft));
    border-color: var(--c, var(--accent));
    color: var(--cfg, var(--accent-strong));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--accent)) 18%, transparent);
}
.chip.is-active .chip__count { background: var(--surface); color: inherit; }
.chip[data-cat=""].is-active {
    background: var(--grad-btn);
    color: var(--accent-text);
    border-color: transparent;
}
.chip[data-cat=""].is-active .chip__count { background: rgba(255, 255, 255, .25); color: inherit; }

.subfilters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}
.subfilter { display: inline-flex; align-items: center; gap: 8px; }
.subfilter__label { font-size: .8rem; font-weight: 700; color: var(--text-muted); }
.subfilter select { width: auto; padding-top: 7px; padding-bottom: 7px; font-size: .88rem; border-radius: 10px; }
.result-count { margin: 0 0 0 auto; font-size: .88rem; color: var(--text-muted); font-weight: 600; }

/* ---------- 11. Cartes des procédures ---------- */
.cards {
    list-style: none;
    margin: 0; padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 18px;
}
.doc-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 18px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .22s;
    animation: rise .45s var(--ease) both;
}
.doc-card::before { /* liseré coloré de la catégorie */
    content: "";
    position: absolute; left: 0; right: 0; top: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 45%, transparent));
}
.doc-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-3);
    border-color: color-mix(in srgb, var(--c) 45%, var(--border));
}
.doc-card:target { box-shadow: 0 0 0 3px var(--c), var(--shadow-3); }
.doc-card:nth-child(2) { animation-delay: .04s; }
.doc-card:nth-child(3) { animation-delay: .08s; }
.doc-card:nth-child(4) { animation-delay: .12s; }
.doc-card:nth-child(5) { animation-delay: .16s; }
.doc-card:nth-child(6) { animation-delay: .2s; }
.doc-card:nth-child(n+7) { animation-delay: .24s; }
.no-anim .doc-card { animation: none; }   /* mise à jour sans rechargement */

.doc-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.doc-card__title {
    margin: 2px 0 0;
    font-size: 1.06rem;
    font-weight: 750;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
}
.doc-card__meta {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
    margin: 0;
    font-size: .85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.doc-card__meta > span { display: inline-flex; align-items: center; gap: 5px; }
.doc-card__ext {
    font-size: .72rem; font-weight: 800; letter-spacing: .05em;
    padding: 1px 7px; border-radius: 6px;
    background: var(--surface-2);
}
.doc-card__author { margin: -4px 0 0; font-size: .8rem; color: var(--text-muted); font-style: italic; }
.doc-card__actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.doc-card__admin {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 6px;
    flex-wrap: wrap;
    margin: 2px -6px -6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.doc-card__admin form { margin: 0; }
.doc-card__edit { flex: 1; min-width: 0; }
.doc-card__edit[open] { flex-basis: 100%; }
.doc-card__edit form {
    margin-top: 8px;
    padding: 12px;
    border-radius: 14px;
    background: var(--surface-2);
}
.doc-card__edit[open] > summary { color: var(--accent); background: var(--accent-soft); }

/* Vignette PDF / DOC */
.file-icon {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 46px; height: 54px;
    flex: none;
}
.file-icon svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.file-icon__sheet { fill: var(--ft-soft); stroke: var(--ft); stroke-width: 2; }
.file-icon__fold { fill: none; stroke: var(--ft); stroke-width: 2; stroke-linejoin: round; }
.file-icon__label {
    position: relative;
    margin-top: 12px;
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--ft);
    color: #fff;
    font: 800 .64rem/1.3 var(--font);
    letter-spacing: .04em;
}
.file-icon--pdf { --ft: var(--pdf); --ft-soft: var(--pdf-soft); }
.file-icon--doc { --ft: var(--doc); --ft-soft: var(--doc-soft); }
@media (prefers-color-scheme: dark) {
    .file-icon__label { color: #0b0e1d; }
}

/* États vides */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-l);
}
.empty-state__icon {
    display: inline-grid; place-items: center;
    width: 56px; height: 56px;
    margin-bottom: 8px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
}
.empty-state__icon .icon { width: 26px; height: 26px; }
.empty-state p { margin: 0; font-weight: 600; }

/* ---------- 12. Fenêtres modales ---------- */
.modal {
    width: min(460px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-3);
}
.modal[open] { animation: modal-in .28s var(--ease); }
.modal::backdrop {
    background: rgba(12, 10, 40, .55);
    backdrop-filter: blur(4px);
    animation: fade-in .25s ease;
}
/* Sans JavaScript (?admin) : la modale est rendue ouverte, non modale */
.no-js .modal[open] {
    position: fixed; inset: 0; margin: auto;
    height: max-content; z-index: 60;
}
.modal__body { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.modal__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.modal__icon {
    display: grid; place-items: center;
    width: 44px; height: 44px; flex: none;
    border-radius: 14px;
    background: var(--grad);
    color: #fff;
}
.modal__icon .icon { width: 22px; height: 22px; }
.modal__title { margin: 0; font-size: 1.2rem; }
.modal__subtitle { margin: 2px 0 0; font-size: .88rem; color: var(--text-muted); }
.modal__close { margin-left: auto; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- 13. Pied de page ---------- */
.footer {
    text-align: center;
    padding: 20px;
    font-size: .82rem;
    color: var(--text-muted);
}
.footer p { margin: 0; }

/* ---------- 14. Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-delay: 0s !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    .doc-card:hover, .chip:hover, .btn--primary:hover { transform: none; }
}

/* ---------- 15. Responsive ---------- */
@media (max-width: 960px) {
    .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .container { padding: 0 14px 28px; }
    .hero__inner { padding: 14px 14px 0; }
    .hero { padding-bottom: 60px; }
    .hero__text { padding: 30px 0 18px; }
    .hero-search input { padding: 14px 18px 14px 46px; font-size: 1rem; }
    .hero-search__kbd { display: none; }
    .topbar .btn span { display: none; }      /* boutons d'en-tête : icône seule */
    .topbar .btn { padding: 10px; }
    .admin-badge { font-size: .74rem; padding: 5px 10px; }
    .panel { padding: 16px; border-radius: var(--radius); }
    .upload-form { grid-template-columns: 1fr; }
    .filters { padding: 12px; border-radius: var(--radius); }
    .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
    .chip { flex: none; }
    .subfilters { display: grid; grid-template-columns: 1fr 1fr; }
    .subfilter { flex-direction: column; align-items: stretch; gap: 4px; }
    .subfilter select { width: 100%; }
    .result-count { margin: 0; grid-column: 1 / -1; }
    #f-reset { grid-column: 1 / -1; }
    .cards { grid-template-columns: 1fr; gap: 14px; }
    .toasts { right: 12px; left: 12px; bottom: 12px; width: auto; }
    .modal__actions .btn { flex: 1; }
}
