/* Répertoire — mobile d'abord (390 px), contenu centré à 480 px maximum. */

:root {
    --fond: #F6F7F9;
    --surface: #FFFFFF;
    --texte: #15171C;
    --texte-2: #5A6070;
    --bordure-champ: #8E95A4;
    --separateur: #E2E5EB;
    --bordure-puce: #D5D9E1;
    --accent: #2340C4;
    --accent-fonce: #1A2F92;
    --accent-clair: #E8ECFB;
    --gris-bouton: #F1F3F6;
    --danger: #B42318;
    --danger-fond: #FDECEA;
    --danger-bordure: #E8B4AE;

    --police-titre: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
    --police: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --largeur-max: 480px;
}

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

html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
html.feuille-ouverte { overflow: hidden; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: var(--police);
    font-size: 16px;
    line-height: 1.4;
}

a { color: var(--accent); }
a:hover { color: var(--accent-fonce); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ecran {
    position: relative;
    max-width: var(--largeur-max);
    min-height: 100dvh;
    margin-inline: auto;
    padding-bottom: 104px; /* place pour le bouton « Ajouter » */
}

/* ---------- Titres et textes ---------- */

.titre-page {
    margin: 0;
    font-family: var(--police-titre);
    font-size: 30px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.titre-page--grand { font-size: 34px; }

.titre-ecran {
    margin: 0;
    font-family: var(--police-titre);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.sous-titre { margin: 2px 0 0; font-size: 14px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.texte-secondaire { margin: 0; line-height: 1.5; color: var(--texte-2); }

/* ---------- Boutons ---------- */

.bouton {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 52px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s, border-color .15s;
}
.bouton--primaire { background: var(--accent); color: #fff; }
.bouton--primaire:hover { background: var(--accent-fonce); color: #fff; }
.bouton--secondaire { background: var(--surface); border-color: var(--bordure-puce); color: var(--texte); }
.bouton--secondaire:hover { background: var(--fond); color: var(--texte); }

.bouton-rond {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--separateur);
    background: var(--surface);
    color: var(--texte-2);
}
.bouton-rond:hover { background: var(--fond); }
.bouton-rond--gris { border-color: transparent; background: var(--gris-bouton); color: var(--texte); }

/* ---------- Champs ---------- */

.formulaire { display: flex; flex-direction: column; gap: 18px; }

.champ { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.champ > label { font-size: 14px; font-weight: 600; }
.champ--compact { gap: 6px; }
.champ--compact > label { font-size: 13px; color: var(--texte-2); }

.saisie {
    height: 52px;
    padding: 0 14px;
    border: 1px solid var(--bordure-champ);
    border-radius: 12px;
    background: var(--surface);
    font-size: 17px;
    outline: none;
}
.saisie:focus, .saisie:focus-within { border: 2px solid var(--accent); padding-inline: 13px; }

.saisie--groupe { display: flex; align-items: center; gap: 8px; padding: 0 0 0 14px; overflow: hidden; }
.saisie--groupe:focus-within { padding-left: 13px; }
.saisie--groupe input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    font-size: inherit;
}
.saisie--date { height: 48px; padding-left: 12px; font-size: 16px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.saisie--date input { color: var(--texte); }
.saisie--date svg { flex: none; }
.saisie--date:focus-within { color: var(--accent); }

.saisie__action {
    height: 100%;
    padding: 0 16px;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
}

.alerte-erreur {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--danger-bordure);
    border-radius: 12px;
    background: var(--danger-fond);
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
}

/* ---------- Connexion ---------- */

.ecran--connexion {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 36px;
    padding: 32px 24px 64px;
}
.connexion__marque { display: flex; flex-direction: column; gap: 14px; }
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent);
    color: #fff;
}
.ecran--connexion .bouton { margin-top: 6px; }
.note-acces { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--texte-2); }

/* ---------- Accueil : en-tête, recherche, puces ---------- */

.entete { display: flex; flex-direction: column; gap: 16px; padding: 28px 20px 4px; }
.entete__ligne { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.recherche {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 14px;
    border: 1px solid var(--bordure-champ);
    border-radius: 12px;
    background: var(--surface);
    color: var(--texte-2);
}
.recherche:focus-within { border: 2px solid var(--accent); padding-inline: 13px; color: var(--accent); }
.recherche svg { flex: none; }
.recherche input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--texte);
}
.recherche input::placeholder { color: var(--texte-2); opacity: .85; }
.recherche input::-webkit-search-cancel-button { display: none; }
.recherche__effacer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 32px;
    height: 32px;
    margin-right: -6px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--gris-bouton);
    color: var(--texte);
}

.puces {
    display: flex;
    gap: 8px;
    margin-inline: -20px;
    padding-inline: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}
.puces::-webkit-scrollbar { display: none; }
.puce {
    display: inline-flex;
    align-items: center;
    flex: none;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--bordure-puce);
    border-radius: 18px;
    background: var(--surface);
    color: var(--texte);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
}
.puce:hover { color: var(--texte); background: var(--fond); }
.puce--actif, .puce--actif:hover { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 600; }

/* ---------- Accueil : liste ---------- */

.compte-resultats { margin: 0; padding: 14px 20px 10px; font-size: 14px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.compte-resultats strong { color: var(--texte); font-weight: 600; }

main#resultats { display: block; padding-top: 6px; }
.compte-resultats + .liste, .compte-resultats ~ .liste { margin-top: 0; }

.groupe__entete {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--texte-2);
    font-variant-numeric: tabular-nums;
}
.groupe__entete h2 { margin: 0; font-size: inherit; letter-spacing: .06em; text-transform: uppercase; }
.groupe--suite .liste { margin-top: -1px; border-top: 0; }

.liste { background: var(--surface); border-bottom: 1px solid var(--separateur); }
.liste--suite { margin-top: -1px; }

.ligne {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 0 20px;
    border-top: 1px solid var(--separateur);
    color: var(--texte);
    text-decoration: none;
}
.ligne:hover { background: var(--fond); color: var(--texte); }
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-clair);
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
}
.ligne__corps { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.ligne__nom { overflow: hidden; font-size: 16px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.ligne__numero { font-size: 14px; color: var(--texte-2); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.ligne__droite { flex: none; font-size: 13px; color: var(--texte-2); font-variant-numeric: tabular-nums; }

mark {
    padding: 0 1px;
    border-radius: 3px;
    background: var(--accent-clair);
    color: var(--accent);
    font-weight: 600;
}

.plus { padding: 16px 20px 0; }

.vide { padding: 56px 32px; text-align: center; color: var(--texte-2); }
.vide p { margin: 0 0 6px; }
.vide__titre { font-family: var(--police-titre); font-size: 20px; font-weight: 700; color: var(--texte); }

.erreur-reseau {
    margin: 16px 20px 0;
    padding: 12px 14px;
    border: 1px solid var(--danger-bordure);
    border-radius: 12px;
    background: var(--danger-fond);
    color: var(--danger);
    font-size: 14px;
}

/* ---------- Bouton flottant ---------- */

.fab {
    position: fixed;
    bottom: 24px;
    right: max(20px, calc((100vw - var(--largeur-max)) / 2 + 20px));
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 22px 0 18px;
    border-radius: 28px;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(35, 64, 196, .28);
}
.fab:hover { background: var(--accent-fonce); color: #fff; }

/* ---------- Feuille du bas (filtre par date) ---------- */

.voile { position: fixed; inset: 0; z-index: 20; background: rgba(21, 23, 28, .48); }

.feuille {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: var(--largeur-max);
    max-height: 92dvh;
    margin-inline: auto;
    padding: 10px 20px 28px;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    background: var(--surface);
    box-shadow: 0 -8px 30px rgba(21, 23, 28, .18);
    animation: feuille-monte .2s ease-out;
}
@keyframes feuille-monte { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.feuille__poignee { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: #C9CED8; }
.feuille__entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.options { display: flex; flex-direction: column; margin: 0; padding: 0; border: 0; }
.option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    border-bottom: 1px solid #EEF0F3;
    cursor: pointer;
}
.option:last-child { border-bottom: 0; }
.option > span:first-of-type { flex: 1; }
.option input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.option__nombre { font-size: 14px; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.option:has(input:checked) { font-weight: 600; }

.dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.feuille__phrase { min-height: 20px; margin: 0; font-size: 14px; color: var(--texte-2); }
.feuille__phrase strong { color: var(--texte); font-weight: 600; font-variant-numeric: tabular-nums; }

.feuille__actions { display: flex; gap: 12px; margin-top: 4px; }
.feuille__actions .bouton:first-child { flex: 1; }
.feuille__actions .bouton:last-child { flex: 2; }

@media (prefers-reduced-motion: reduce) {
    .feuille { animation: none; }
    .bouton { transition: none; }
}

/* ---------- Écrans secondaires : formulaire, fiche ---------- */

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

.ecran--formulaire, .ecran--fiche { padding-bottom: 168px; } /* place pour la barre d actions */

.entete-ecran { display: flex; align-items: center; gap: 4px; padding: 20px 12px 8px; }
.bouton-retour {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--texte);
}
.bouton-retour:hover { background: var(--gris-bouton); color: var(--texte); }
.lien-retour {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 44px;
    padding: 0 10px 0 6px;
    border-radius: 22px;
    font-weight: 600;
    text-decoration: none;
}

.formulaire--ecran { gap: 24px; padding: 16px 20px; }
.etiquette { font-size: 14px; font-weight: 600; }

.saisie--prefixe, .saisie--prefixe:focus-within { gap: 0; padding: 0; }
.saisie__prefixe {
    display: flex;
    align-items: center;
    align-self: stretch;
    padding: 0 12px;
    border-right: 1px solid var(--bordure-puce);
    background: var(--gris-bouton);
    color: var(--texte-2);
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.saisie--prefixe input { padding: 0 14px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

.saisie--erreur, .saisie--erreur:focus-within { border: 2px solid var(--danger); }
.saisie--alerte, .saisie--alerte:focus-within { border: 2px solid #C27C0E; }

.aide { margin: 0; font-size: 13px; color: var(--texte-2); }
.erreur-champ { margin: 0; font-size: 14px; font-weight: 500; color: var(--danger); }

.alerte-doublon {
    display: flex;
    gap: 12px;
    padding: 14px 14px 6px;
    border: 1px solid #EDC36A;
    border-radius: 12px;
    background: #FFF3D6;
    color: #6E4500;
}
.alerte-doublon > svg { flex: none; margin-top: 1px; }
.alerte-doublon__corps { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.alerte-doublon__corps p { margin: 0; font-size: 14px; line-height: 1.45; }
.alerte-doublon__titre { font-size: 15px !important; font-weight: 600; }
.alerte-doublon__lien {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    min-height: 44px;
    color: #6E4500;
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.alerte-doublon__lien:hover { color: #6E4500; }

.date-auto {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #ECEEF2;
    color: var(--texte-2);
}
.date-auto svg { flex: none; }
.date-auto__texte { display: flex; flex-direction: column; gap: 2px; }
.date-auto__jour { color: var(--texte); font-size: 16px; font-weight: 600; }
.date-auto__detail { font-size: 13px; font-variant-numeric: tabular-nums; }

.barre-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: var(--largeur-max);
    margin-inline: auto;
    padding: 16px 20px 28px;
    border-top: 1px solid var(--separateur);
    background: var(--fond);
}
.barre-actions--double { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.bouton--danger { background: var(--danger); color: #fff; }
.bouton--danger:hover { background: #8F1D14; color: #fff; }
.bouton--danger-contour { background: var(--surface); border-color: var(--danger-bordure); color: var(--danger); }
.bouton--danger-contour:hover { background: var(--danger-fond); color: var(--danger); }

/* Fiche */

.profil { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 20px 24px; text-align: center; }
.avatar--grand { width: 76px; height: 76px; font-family: var(--police-titre); font-size: 28px; font-weight: 700; }
.profil__nom {
    margin: 8px 0 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-family: var(--police-titre);
    font-size: 28px;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.profil__numero { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.pilule {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    margin-top: 6px;
    padding: 0 16px;
    border: 1px solid var(--bordure-puce);
    border-radius: 22px;
    background: var(--surface);
    font-size: 14px;
    font-weight: 600;
}
.pilule:hover { background: var(--fond); }

.details { display: flex; flex-direction: column; margin: 0; border-block: 1px solid var(--separateur); background: var(--surface); }
.details > div { display: flex; flex-direction: column; gap: 3px; padding: 14px 20px; }
.details > div + div { border-top: 1px solid var(--separateur); }
.details dt { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--texte-2); }
.details dd { margin: 0; font-variant-numeric: tabular-nums; }

.carte-lien {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 20px 0;
    padding: 14px;
    border-radius: 12px;
    background: var(--accent-clair);
    color: var(--texte);
    text-decoration: none;
}
.carte-lien:hover { color: var(--texte); background: #DCE3F9; }
.carte-lien > svg { flex: none; stroke: var(--accent); }
.carte-lien__corps { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.carte-lien__titre { font-size: 15px; font-weight: 600; }
.carte-lien__detail { font-size: 14px; color: #3B4152; }

/* Confirmation de suppression */

.feuille--suppression { gap: 14px; }
.icone-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-top: 8px;
    border-radius: 50%;
    background: var(--danger-fond);
    color: var(--danger);
}
.texte-suppression { margin: 0; font-size: 15px; line-height: 1.5; color: var(--texte-2); }
.texte-suppression strong { color: var(--texte); font-weight: 600; font-variant-numeric: tabular-nums; }
.feuille__pile { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

/* Message de confirmation (enregistré, supprimé) */

.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 40;
    max-width: min(440px, calc(100vw - 32px));
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--texte);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 8px 24px rgba(21, 23, 28, .24);
    transform: translateX(-50%);
    animation: toast 4s ease-in-out forwards;
}
@keyframes toast {
    0% { opacity: 0; transform: translate(-50%, -8px); }
    8%, 85% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 0); visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; }
}
