/* =========================================================================
   INFSS Scolarité — Champs intelligents (Smart Fields)
   Couche de présentation premium des saisies : états, assistances,
   suggestions, listes filtrables, jauges, compteurs et dépôts de fichiers.
   Aucune dépendance externe. S'appuie sur les jetons de app.css.
   ========================================================================= */

/* ------------------------------------------------------------- 1. Jetons */
:root {
    --sf-ok: #2f7a49;
    --sf-ok-bg: #edf7f0;
    --sf-ok-line: #a9d9bb;
    --sf-warn: #a3620c;
    --sf-warn-bg: #fdf6ea;
    --sf-warn-line: #efd0a1;
    --sf-err: #b42318;
    --sf-err-bg: #fff7f7;
    --sf-err-line: #f0b4b4;
    --sf-info: #01628d;
    --sf-info-bg: #f1f8fc;
    --sf-ring: 0 0 0 3px var(--brand-50);
    --sf-ring-ok: 0 0 0 3px rgba(102, 179, 62, .16);
    --sf-ring-err: 0 0 0 3px rgba(229, 72, 77, .13);
    --sf-pop-sh: 0 18px 44px rgba(12, 40, 60, .16), 0 2px 6px rgba(12, 40, 60, .06);
}

/* -------------------------------------------------- 2. Enveloppe de saisie */
.sf-control {
    position: relative;
    display: block;
    min-width: 0;
    /* Le champ enveloppé peut être l'enfant direct d'un conteneur flex
       (barre de recherche, ligne de filtres) : on reprend le comportement
       d'élasticité que portait l'élément d'origine. */
    flex: 1 1 auto;
}

/* Réserve la place de la pastille d'état sans casser les gabarits existants. */
.sf-control.has-status > input:not([type="checkbox"]):not([type="radio"]),
.sf-control.has-status > select { padding-right: 40px; }
.sf-control.has-status > textarea { padding-right: 38px; }

.sf-status {
    position: absolute;
    right: 13px;
    top: 22px;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    display: grid;
    place-items: center;
    pointer-events: none;
    opacity: 0;
    transform: scale(.7);
    transition: opacity .18s var(--ease), transform .18s var(--ease);
    color: var(--muted-2);
}
.sf-control.is-textarea .sf-status { top: 26px; }
.sf-status svg { display: block; }
.sf-status.is-shown { opacity: 1; transform: scale(1); }
.sf-status.is-ok { color: var(--green-700); }
.sf-status.is-error { color: var(--sf-err); }
.sf-status.is-warn { color: var(--sf-warn); }
.sf-status.is-busy { color: var(--brand-400); }
.sf-status.is-busy svg { animation: sf-spin 900ms linear infinite; }

@keyframes sf-spin { to { transform: rotate(360deg); } }

/* Le sélecteur conserve son chevron : la pastille se décale. */
.sf-control.is-select .sf-status { right: 34px; }

/* ------------------------------------------------------- 3. États du champ */
.field.is-valid > label,
.field.is-valid .form-label { color: var(--ink-2); }

.field.is-valid input:not([type="checkbox"]):not([type="radio"]),
.field.is-valid select,
.field.is-valid textarea {
    border-color: var(--sf-ok-line);
}
.field.is-valid input:focus,
.field.is-valid select:focus,
.field.is-valid textarea:focus {
    border-color: var(--green); box-shadow: var(--sf-ring-ok);
}

.field.has-error input:not([type="checkbox"]):not([type="radio"]),
.field.has-error select,
.field.has-error textarea {
    border-color: var(--sf-err-line);
    background: var(--sf-err-bg);
}
.field.has-error input:focus,
.field.has-error select:focus,
.field.has-error textarea:focus {
    border-color: var(--red); box-shadow: var(--sf-ring-err);
}

.field.is-warned input:not([type="checkbox"]),
.field.is-warned select,
.field.is-warned textarea { border-color: var(--sf-warn-line); }

.field.is-busy input { background-image: none; }

/* Secousse discrète au refus de soumission. */
@keyframes sf-shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-3px); }
    40%, 60% { transform: translateX(3px); }
}
.field.sf-shake .sf-control { animation: sf-shake .42s cubic-bezier(.36, .07, .19, .97); }

/* ------------------------------------------------------ 4. Ligne de message */
.field .sf-note,
.field .field-error,
.field .error {
    display: none;
    gap: 7px;
    align-items: flex-start;
    margin-top: 7px;
    font-size: 12.5px;
    line-height: 1.45;
    font-weight: 600;
    color: var(--sf-err);
}
.field .sf-note.is-shown,
.field .field-error.is-shown,
.field .error.is-shown { display: flex; }

.field .sf-note .sf-note-ic { flex: 0 0 auto; margin-top: 1px; }
.field .sf-note.is-ok { color: var(--sf-ok); }
.field .sf-note.is-warn { color: var(--sf-warn); }
.field .sf-note.is-info { color: var(--sf-info); font-weight: 600; }
.field .sf-note.is-error { color: var(--sf-err); }

/* Les indices statiques restent lisibles et légèrement plus doux. */
.field .hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.45; }

/* ------------------------------------------------- 5. Assistances dynamiques */
.sf-assist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
    align-items: center;
}
.sf-assist:empty { display: none; }

.sf-fact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--body);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.sf-fact.is-ok { background: var(--sf-ok-bg); border-color: var(--sf-ok-line); color: var(--sf-ok); }
.sf-fact.is-warn { background: var(--sf-warn-bg); border-color: var(--sf-warn-line); color: var(--sf-warn); }
.sf-fact.is-info { background: var(--sf-info-bg); border-color: var(--brand-100); color: var(--sf-info); }
.sf-fact .ic { flex: 0 0 auto; }

/* Bouton d'application d'une proposition (correction, valeur suggérée). */
.sf-apply {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    border: 1px dashed var(--brand-300);
    background: var(--brand-50);
    color: var(--brand-600);
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease);
}
.sf-apply:hover { background: var(--brand-100); border-style: solid; color: var(--brand-700); }
.sf-apply:active { transform: translateY(1px); }

/* Valeurs rapides (années, raccourcis de date, motifs fréquents). */
.sf-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sf-quick button {
    padding: 4px 11px;
    border-radius: var(--r-full);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--body);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .14s var(--ease);
}
.sf-quick button:hover { border-color: var(--brand-300); color: var(--brand-600); background: var(--brand-50); }
.sf-quick button.is-active { border-color: var(--brand-450); background: var(--brand-450); color: #fff; }

/* --------------------------------------------------- 6. Boutons intégrés */
.sf-tools {
    position: absolute;
    right: 6px;
    top: 22px;
    margin-top: -15px;
    display: flex;
    gap: 2px;
    align-items: center;
}
.sf-control.is-textarea .sf-tools { top: 16px; margin-top: 0; }

.sf-tool {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--muted-2);
    cursor: pointer;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.sf-tool:hover { background: var(--surface-2); color: var(--brand-450); }
.sf-tool:active { background: var(--brand-50); }
.sf-tool[hidden] { display: none; }

/* Quand des outils sont présents, on réserve la gouttière. */
.sf-control.has-tools > input:not([type="checkbox"]) { padding-right: 44px; }
.sf-control.has-tools.has-status > input:not([type="checkbox"]) { padding-right: 70px; }
.sf-control.has-tools.has-status .sf-status { right: 42px; }
.sf-control.has-tools.two-tools > input:not([type="checkbox"]) { padding-right: 76px; }
.sf-control.has-tools.two-tools.has-status > input:not([type="checkbox"]) { padding-right: 102px; }
.sf-control.has-tools.two-tools.has-status .sf-status { right: 74px; }

/* Compatibilité avec .input-icon (bouton « afficher le mot de passe »). */
.input-icon .sf-control.has-status > input { padding-right: 74px; }
.input-icon .sf-control.has-status .sf-status { right: 46px; }

/* --------------------------------------------------- 7. Compteur de texte */
.sf-count {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}
.sf-count b { font-weight: 700; color: var(--body); }
.sf-count.is-near b { color: var(--sf-warn); }
.sf-count.is-over b { color: var(--sf-err); }
.sf-count .sf-count-left { color: var(--muted-2); }

/* --------------------------------------------- 8. Robustesse du mot de passe */
.sf-strength { margin-top: 10px; }

.sf-strength-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    height: 5px;
}
.sf-strength-bar i {
    display: block;
    border-radius: var(--r-full);
    background: var(--line);
    transition: background .25s var(--ease);
}
.sf-strength[data-score="1"] .sf-strength-bar i:nth-child(-n+1) { background: var(--red); }
.sf-strength[data-score="2"] .sf-strength-bar i:nth-child(-n+2) { background: var(--orange); }
.sf-strength[data-score="3"] .sf-strength-bar i:nth-child(-n+3) { background: #d3b400; }
.sf-strength[data-score="4"] .sf-strength-bar i { background: var(--green); }

.sf-strength-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-top: 7px;
    font-size: 12px;
}
.sf-strength-label { font-weight: 800; color: var(--ink-2); }
.sf-strength[data-score="1"] .sf-strength-label { color: var(--red-700); }
.sf-strength[data-score="2"] .sf-strength-label { color: var(--sf-warn); }
.sf-strength[data-score="3"] .sf-strength-label { color: var(--amber-700); }
.sf-strength[data-score="4"] .sf-strength-label { color: var(--green-700); }
.sf-strength-time { color: var(--muted); font-variant-numeric: tabular-nums; }

.sf-rules {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 5px 14px;
}
.sf-rules li {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--muted);
    transition: color .16s var(--ease);
}
.sf-rules li .sf-dot {
    width: 15px; height: 15px; flex: 0 0 auto;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    display: grid; place-items: center;
    color: transparent;
    transition: all .16s var(--ease);
}
.sf-rules li.is-met { color: var(--green-700); font-weight: 600; }
.sf-rules li.is-met .sf-dot { border-color: var(--green); background: var(--green); color: #fff; }

/* ---------------------------------------------- 9. Liste filtrable (combo) */
.sf-combo { position: relative; display: block; min-width: 0; }
/* Ancré en haut à gauche de son conteneur : à sa position statique, il étendait la zone défilante de la page. */
.sf-native { position: absolute !important; left: 0; top: 0; margin: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; pointer-events: none; }

.sf-combo-btn {
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.sf-combo-btn:hover { border-color: var(--brand-300); }
.sf-combo-btn[aria-expanded="true"] { border-color: var(--brand-400); box-shadow: var(--sf-ring); }
.sf-combo-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-combo-value.is-placeholder { color: var(--muted-2); }
.sf-combo-caret { flex: 0 0 auto; color: var(--muted); transition: transform .18s var(--ease); }
.sf-combo-btn[aria-expanded="true"] .sf-combo-caret { transform: rotate(180deg); color: var(--brand-450); }
.sf-combo-clear { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 0; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.sf-combo-clear:hover { background: var(--red-50); color: var(--red-700); }

.field.has-error .sf-combo-btn { border-color: var(--sf-err-line); background: var(--sf-err-bg); }
.field.is-valid .sf-combo-btn { border-color: var(--sf-ok-line); }

.sf-combo-pop {
    position: absolute;
    z-index: 60;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    min-width: 248px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sf-pop-sh);
    overflow: hidden;
    animation: sf-pop .14s var(--ease);
}
.sf-combo-pop.is-up { top: auto; bottom: calc(100% + 6px); }
.sf-combo-pop[hidden] { display: none; }

@keyframes sf-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.sf-combo-search {
    position: relative;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line-2);
    background: var(--surface-2);
}
.sf-combo-search input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 13.5px;
    outline: 0;
}
.sf-combo-search input:focus { border-color: var(--brand-300); box-shadow: var(--sf-ring); }
.sf-combo-search .ic { position: absolute; left: 21px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }

.sf-combo-list {
    list-style: none;
    margin: 0;
    padding: 6px;
    max-height: min(300px, 46vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.sf-combo-group {
    padding: 8px 10px 4px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted-2);
}
.sf-combo-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    color: var(--ink-2);
    cursor: pointer;
    scroll-margin: 8px;
}
.sf-combo-item .sf-combo-tick { flex: 0 0 auto; width: 16px; color: transparent; }
.sf-combo-item[aria-selected="true"] { font-weight: 700; color: var(--brand-600); }
.sf-combo-item[aria-selected="true"] .sf-combo-tick { color: var(--brand-450); }
.sf-combo-item.is-active { background: var(--brand-50); color: var(--brand-700); }
.sf-combo-item mark { background: #fdf0c9; color: inherit; border-radius: 3px; padding: 0 1px; font-weight: 800; }
.sf-combo-item .sf-combo-meta { margin-left: auto; font-size: 11px; color: var(--muted-2); font-weight: 600; }

.sf-combo-empty { padding: 20px 14px; text-align: center; font-size: 13px; color: var(--muted); }
.sf-combo-foot {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-top: 1px solid var(--line-2);
    background: var(--surface-2);
    font-size: 11px;
    color: var(--muted-2);
}
.sf-combo-foot kbd {
    font: inherit; font-weight: 700;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 4px; padding: 1px 5px; color: var(--muted);
}

/* Le conteneur des filtres ne doit pas rogner la liste. */
.filters, .toolbar, .filter-bar, .formgrid, .form-grid { overflow: visible; }
label.filter:has(.sf-combo) { padding: 0; border: 0; background: transparent; }
label.filter .sf-combo-btn { height: 42px; font-size: 13.5px; }

/* ------------------------------------------------ 10. Suggestions de saisie */
.sf-suggest {
    position: absolute;
    z-index: 55;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sf-pop-sh);
    padding: 5px;
    max-height: 240px;
    overflow-y: auto;
    animation: sf-pop .14s var(--ease);
}
.sf-suggest[hidden] { display: none; }
.sf-suggest-head {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 6px 9px 4px; font-size: 10.5px; font-weight: 800;
    letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2);
}
.sf-suggest-head button { border: 0; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 700; cursor: pointer; text-transform: none; letter-spacing: 0; }
.sf-suggest-head button:hover { color: var(--red-700); text-decoration: underline; }
.sf-suggest-item {
    display: flex; align-items: center; gap: 9px;
    width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
    background: transparent; text-align: left; font-size: 13.5px; color: var(--ink-2); cursor: pointer;
}
.sf-suggest-item:hover, .sf-suggest-item.is-active { background: var(--brand-50); color: var(--brand-700); }
.sf-suggest-item .ic { color: var(--muted-2); flex: 0 0 auto; }
.sf-suggest-item .sf-suggest-sub { margin-left: auto; font-size: 11px; color: var(--muted-2); }
.sf-suggest-item mark { background: #fdf0c9; color: inherit; border-radius: 3px; font-weight: 800; }

/* ------------------------------------------------- 11. Saisie de code (OTP) */
.sf-otp { display: flex; gap: 8px; }
.sf-otp input {
    width: 46px !important;
    height: 54px;
    padding: 0 !important;
    text-align: center;
    font: 800 21px/1 var(--font-title);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .12s var(--ease);
}
.sf-otp input:focus { border-color: var(--brand-400); box-shadow: var(--sf-ring); outline: 0; transform: translateY(-1px); }
.sf-otp input.is-filled { border-color: var(--brand-300); background: var(--brand-50); }
.sf-otp.is-complete input { border-color: var(--green); background: var(--sf-ok-bg); }
.sf-otp.is-error input { border-color: var(--sf-err-line); background: var(--sf-err-bg); }
@media (max-width: 420px) { .sf-otp { gap: 6px; } .sf-otp input { width: 40px !important; height: 48px; font-size: 18px; } }

.sf-otp-alt {
    margin-top: 10px;
    display: inline-flex; align-items: center; gap: 7px;
    border: 0; background: transparent; padding: 0;
    color: var(--brand-450); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.sf-otp-alt:hover { text-decoration: underline; }

/* ---------------------------------------------------- 12. Dépôt de fichier */
.sf-drop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border: 1.5px dashed var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .16s var(--ease), background .16s var(--ease);
}
.sf-drop:hover, .sf-drop:focus-within { border-color: var(--brand-300); background: var(--brand-50); }
.sf-drop.is-dragging { border-color: var(--brand-450); background: var(--brand-100); border-style: solid; }
.sf-drop.has-file { border-style: solid; border-color: var(--sf-ok-line); background: var(--sf-ok-bg); }
.sf-drop.is-invalid { border-color: var(--sf-err-line); background: var(--sf-err-bg); }
.sf-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.sf-drop-icon {
    width: 44px; height: 44px; flex: 0 0 auto;
    border-radius: var(--r-md);
    display: grid; place-items: center;
    background: var(--surface); border: 1px solid var(--line); color: var(--brand-450);
}
.sf-drop.has-file .sf-drop-icon { color: var(--green-700); border-color: var(--sf-ok-line); }
.sf-drop-body { min-width: 0; flex: 1 1 auto; }
.sf-drop-title { font-size: 13.5px; font-weight: 700; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-drop-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.sf-drop-reset {
    position: relative; z-index: 2;
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; border: 1px solid var(--line);
    background: var(--surface); color: var(--muted); cursor: pointer;
}
.sf-drop-reset:hover { color: var(--red-700); border-color: var(--sf-err-line); }

/* ------------------------------------------- 13. Récapitulatif et progression */
.sf-summary {
    border: 1px solid var(--sf-err-line);
    background: var(--sf-err-bg);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    margin-bottom: 18px;
    animation: sf-pop .18s var(--ease);
}
.sf-summary-head {
    display: flex; align-items: center; gap: 10px;
    font: 800 14px/1.3 var(--font-title); color: var(--sf-err);
}
.sf-summary ol { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 5px; }
.sf-summary li { font-size: 13px; color: var(--body); }
.sf-summary a { color: var(--sf-err); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.sf-summary a:hover { color: #8f1d13; }

.sf-progress {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}
.sf-progress-track {
    width: 108px; height: 6px; flex: 0 0 auto;
    background: var(--line); border-radius: var(--r-full); overflow: hidden;
}
.sf-progress-track i {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, var(--brand-400), var(--cyan));
    border-radius: var(--r-full);
    transition: width .3s var(--ease), background .3s var(--ease);
}
.sf-progress.is-complete .sf-progress-track i { background: linear-gradient(90deg, var(--green), var(--green-600)); }
.sf-progress.is-complete { color: var(--green-700); }

/* ---------------------------------------------------- 14. Brouillon restauré */
.sf-draft {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 16px;
    border: 1px solid var(--brand-100);
    background: var(--sf-info-bg);
    border-radius: var(--r-lg);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--brand-700);
    animation: sf-pop .18s var(--ease);
}
.sf-draft .ic { color: var(--brand-450); flex: 0 0 auto; }
.sf-draft-actions { margin-left: auto; display: flex; gap: 8px; }
.sf-draft button {
    border: 1px solid var(--brand-300); background: var(--surface);
    color: var(--brand-600); font-size: 12px; font-weight: 700;
    padding: 6px 13px; border-radius: var(--r-full); cursor: pointer;
    transition: all .14s var(--ease);
}
.sf-draft button:hover { background: var(--brand-450); border-color: var(--brand-450); color: #fff; }
.sf-draft button.ghost { border-color: var(--line); color: var(--muted); }
.sf-draft button.ghost:hover { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); }

.sf-saved {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11.5px; color: var(--muted-2); font-weight: 600;
}
.sf-saved .ic { color: var(--green); }

/* --------------------------------------------------------- 15. Aide (info) */
.sf-help {
    display: inline-grid; place-items: center;
    width: 16px; height: 16px; margin-left: 6px; vertical-align: -3px;
    border-radius: 50%; border: 1.4px solid var(--muted-2);
    color: var(--muted-2); background: transparent;
    font: 800 10px/1 var(--font); cursor: help; padding: 0;
    transition: all .14s var(--ease);
}
.sf-help:hover, .sf-help:focus-visible { border-color: var(--brand-450); color: var(--brand-450); background: var(--brand-50); }

.sf-tip {
    position: absolute;
    z-index: 70;
    max-width: 280px;
    padding: 10px 13px;
    border-radius: var(--r-md);
    background: var(--ink);
    color: #eaf2f7;
    font-size: 12px;
    line-height: 1.5;
    font-weight: 500;
    box-shadow: var(--sh-lg);
    pointer-events: none;
    animation: sf-pop .12s var(--ease);
}
.sf-tip::after {
    content: ''; position: absolute; left: var(--sf-tip-x, 16px); top: 100%;
    border: 6px solid transparent; border-top-color: var(--ink);
}
.sf-tip.is-below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ink); }

/* ------------------------------------------------ 16. Champ en lecture seule */
.field.is-readonly input,
.field.is-readonly select,
.field.is-readonly textarea { background: var(--surface-2); color: var(--body); }

/* ------------------------------------------------------- 17. Accessibilité */
@media (prefers-reduced-motion: reduce) {
    .sf-status, .sf-combo-pop, .sf-suggest, .sf-draft, .sf-summary, .sf-tip,
    .field.sf-shake .sf-control, .sf-status.is-busy svg {
        animation: none !important;
        transition: none !important;
    }
    .sf-progress-track i { transition: none; }
}

@media (forced-colors: active) {
    .sf-combo-btn, .sf-drop, .sf-otp input { border: 1px solid ButtonBorder; }
    .sf-combo-item.is-active { background: Highlight; color: HighlightText; }
}

/* ---------------------------------------------------------- 18. Impression */
@media print {
    .sf-tools, .sf-status, .sf-quick, .sf-progress, .sf-draft,
    .sf-combo-pop, .sf-suggest, .sf-strength, .sf-count { display: none !important; }
    .sf-combo-btn { border: 0; padding: 0; height: auto; }
}

/* =========================================================================
   19. Compléments de mise en page des formulaires

   Les vues emploient quelques classes de structure qui n'existaient pas
   encore dans app.css (.formgrid, .filters, .notice, .login-*, .title…).
   Sans elles, les champs se présentaient sans grille ni carte. On les
   définit ici avec les mêmes jetons que le reste de l'interface.
   ========================================================================= */

/* Grille de formulaire --------------------------------------------------- */
.formgrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px 22px;
    align-items: start;
}
.formgrid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.formgrid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.formgrid > .field.span-2 { grid-column: span 2; }
.formgrid > .field.span-full { grid-column: 1 / -1; }

@media (max-width: 760px) {
    .formgrid, .formgrid.two, .formgrid.three { grid-template-columns: 1fr; }
    .formgrid > .field.span-2 { grid-column: auto; }
}

/* Intitulés de section --------------------------------------------------- */
.card > .title, h2.title, h3.title {
    font: 800 16px/1.3 var(--font-title);
    color: var(--ink);
    margin: 0 0 16px;
    display: flex;
    align-items: baseline;
    gap: 9px;
    flex-wrap: wrap;
}
h3.title { font-size: 14.5px; }
.title .sub, .sub {
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
}

/* Case à cocher pleine largeur ------------------------------------------ */
.field-inline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.field-inline:hover { border-color: var(--brand-300); background: var(--brand-50); }
.field-inline:focus-within { border-color: var(--brand-400); box-shadow: var(--sf-ring); }
.field-inline input[type="checkbox"], .field-inline input[type="radio"] {
    width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--brand-450); cursor: pointer;
}
.field-inline label { font-size: 13.5px; line-height: 1.5; color: var(--ink-2); cursor: pointer; margin: 0; font-weight: 500; }

/* Barre d'outils et filtres ---------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-xs);
    margin-bottom: 18px;
}
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }

label.filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    position: relative;
}
label.filter > span[aria-hidden="true"] {
    position: absolute; left: 12px; color: var(--muted-2); pointer-events: none; font-size: 15px;
}
label.filter > span[aria-hidden="true"] + input { padding-left: 32px; }
label.filter input, label.filter select {
    height: 42px;
    padding: 0 13px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink);
    font-size: 13.5px;
    outline: 0;
    max-width: 100%;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
label.filter select { appearance: none; cursor: pointer; padding-right: 34px;
    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='%236b8393' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center; }
label.filter input:focus, label.filter select:focus { border-color: var(--brand-300); box-shadow: var(--sf-ring); }
label.filter.is-active input, label.filter.is-active select,
label.filter.is-active .sf-combo-btn { border-color: var(--brand-400); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

/* Boutons secondaires ---------------------------------------------------- */
.pill {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 17px;
    border: 1px solid var(--line); border-radius: var(--r-full);
    background: var(--surface); color: var(--ink-2);
    font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: all .15s var(--ease);
}
.pill:hover { border-color: var(--brand-300); color: var(--brand-600); background: var(--brand-50); text-decoration: none; }
.pill.sm { height: 36px; padding: 0 14px; font-size: 13px; }
.pill.block { width: 100%; }

/* Encarts d'information -------------------------------------------------- */
.notice {
    display: flex; align-items: flex-start; gap: 13px;
    padding: 14px 17px;
    border: 1px solid var(--brand-100);
    border-left: 3px solid var(--brand-400);
    background: var(--sf-info-bg);
    border-radius: var(--r-md);
    font-size: 13px; line-height: 1.55; color: var(--body);
}
.notice b { display: block; color: var(--ink-2); margin-bottom: 2px; }
.notice .ico-lg { font-size: 17px; line-height: 1.2; color: var(--brand-450); flex: 0 0 auto; }
.notice.warn { border-color: var(--sf-warn-line); border-left-color: var(--orange); background: var(--sf-warn-bg); }
.notice.warn .ico-lg { color: var(--orange-600); }
.notice.danger { border-color: var(--sf-err-line); border-left-color: var(--red); background: var(--sf-err-bg); }
.notice.danger .ico-lg { color: var(--red); }
.notice.ok, .notice.succes { border-color: var(--sf-ok-line); border-left-color: var(--green); background: var(--sf-ok-bg); }
.notice.ok .ico-lg { color: var(--green-600); }

/* Pages d'authentification secondaires (oubli, code, réinitialisation) --- */
.login { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 34px; align-items: start;
    max-width: 1040px; margin: 0 auto; padding: 46px 26px 60px; }
.login-panel { min-width: 0; }
.login-logo img { height: 48px; width: auto; }
.login h1 { font: 800 30px/1.2 var(--font-title); color: var(--ink); margin: 24px 0 12px; }
.login .intro { font-size: 14.5px; color: var(--body); max-width: 46ch; margin: 0 0 22px; }
.login-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-2xl);
    box-shadow: var(--sh-md); padding: 26px 28px 28px;
}
.login-card .field + .field, .login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; }
.login-links { display: flex; justify-content: space-between; gap: 16px; margin-top: 18px; font-size: 13px; }
.login-meta { font-size: 12px; color: var(--muted); margin: 16px 0 0; line-height: 1.55; }
.login-side { position: sticky; top: 26px; }
.login-side .quote {
    background: var(--brand-900); color: #dbeaf2; border-radius: var(--r-xl);
    padding: 22px 24px; font-size: 13.5px; line-height: 1.6;
}
.login-side .quote b { display: block; color: #fff; font: 800 15px/1.3 var(--font-title); margin-bottom: 8px; }

@media (max-width: 900px) {
    .login { grid-template-columns: 1fr; padding: 30px 18px 48px; }
    .login-side { position: static; }
    .login h1 { font-size: 25px; }
}

/* Bouton d'effacement de la recherche globale ---------------------------- */
.search-box .search-clear {
    width: 26px; height: 26px; flex: 0 0 auto;
    display: grid; place-items: center;
    border: 0; border-radius: 50%;
    background: var(--surface); color: var(--muted);
    cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease);
}
.search-box .search-clear:hover { background: var(--red-50); color: var(--red-700); }
.search-box .search-clear[hidden], .sf-drop-reset[hidden], .sf-tool[hidden] { display: none !important; }
