/*
 * Finance Copro — back-office admin.
 *
 * Charte reprise du site finance-copro.fr : vert de marque pour les actions,
 * bleu nuit pour les surfaces sombres et les titres, boutons en pilule,
 * intitulés de section en capitales espacées. Feuille unique, sans dépendance.
 */

:root {
    /* Marque */
    --vert: #2aa23e;
    --vert-fonce: #1f8531;
    --vert-profond: #0d3b2a;
    --vert-clair: #8ee24e;
    --vert-pale: #eaf6ec;
    --nuit: #16243d;
    --nuit-clair: #24334e;

    /* Texte et surfaces */
    --texte: #16243d;
    --texte-doux: #5f6d80;
    --bordure: #e0e6e2;
    --fond: #f4f7f5;
    --blanc: #fff;

    /* États */
    --bleu: #2f5c9e;
    --bleu-pale: #eaf0f9;
    --orange: #9a5b0b;
    --orange-pale: #fdf1de;
    --rouge: #b3261e;
    --rouge-pale: #fdeceb;
    --gris-pale: #eceff0;
    --violet: #6b3fa0;
    --violet-pale: #f2ecfa;
    --sarcelle: #0f6f74;
    --sarcelle-pale: #e4f2f2;

    --radius: 8px;
    --pilule: 999px;
    --ombre: 0 1px 2px rgba(22, 36, 61, .05), 0 1px 3px rgba(22, 36, 61, .08);
}

* { box-sizing: border-box; }
/* L'attribut hidden gagne TOUJOURS : sans ce garde-fou, toute règle posant un
   display (ex. .formulaire en flex) rend l'élément visible malgré hidden. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--fond);
    color: var(--texte);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.55;
}

a { color: var(--vert-fonce); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 23px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--texte-doux); margin: 0 0 10px; }

/* ── En-tête ─────────────────────────────────────────────── */
.entete {
    background: var(--nuit);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 26px;
    /* Rappel du filet vert qui souligne la baseline du site. */
    border-bottom: 3px solid var(--vert);
}
.entete .marque {
    display: flex; align-items: center; gap: 9px;
    padding: 12px 0; white-space: nowrap;
    color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.entete .marque img { width: 30px; height: 30px; display: block; }
.entete nav { display: flex; gap: 2px; flex: 1; }
.entete nav a {
    color: rgba(255, 255, 255, .72);
    padding: 17px 14px;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    text-decoration: none;
    font-size: 13.5px;
    letter-spacing: .01em;
}
.entete nav a:hover { color: #fff; }
.entete nav a.actif { color: #fff; font-weight: 600; border-bottom-color: var(--vert-clair); }
.entete .compte { color: rgba(255, 255, 255, .72); font-size: 13px; display: flex; align-items: center; gap: 14px; }
.entete .compte a { color: #fff; }

.conteneur { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* ── Titre de page ───────────────────────────────────────── */
.titre-page { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.titre-page .sous-titre { color: var(--texte-doux); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Onglets ─────────────────────────────────────────────── */
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bordure); margin-bottom: 20px; }
.onglets a {
    padding: 9px 16px; color: var(--texte-doux); text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.onglets a:hover { color: var(--texte); text-decoration: none; }
.onglets a.actif { color: var(--vert-profond); border-bottom-color: var(--vert); font-weight: 700; }
.onglets .compteur {
    display: inline-block; margin-left: 5px; padding: 0 7px; border-radius: var(--pilule);
    background: var(--gris-pale); color: var(--texte-doux); font-size: 12px; font-weight: 600;
}
.onglets a.actif .compteur { background: var(--vert-pale); color: var(--vert-fonce); }
/* Pastille signalant qu'il reste quelque chose à faire sur cet onglet. */
.onglets .compteur.attention,
.onglets a.actif .compteur.attention { background: var(--orange-pale); color: var(--orange); }
.onglets .compteur.alerte,
.onglets a.actif .compteur.alerte { background: var(--rouge-pale); color: var(--rouge); }
/* Sous-navigation d'une section (ex. Communiquer : envois / à relancer),
   rendue juste sous la barre d'onglets du dossier — plus discrète, sans trait. */
.sous-onglets { border-bottom: 0; margin: -12px 0 16px; }
.sous-onglets a { padding: 6px 12px; font-size: 13px; }

/* ── Détail déplié d'un copropriétaire ───────────────────── */
.cellule-depliant { width: 46px; padding-right: 0 !important; }
.btn-depliant {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; padding: 0; cursor: pointer;
    background: var(--blanc); border: 1px solid var(--bordure); border-radius: 6px;
    color: var(--texte); vertical-align: middle;
}
.btn-depliant svg { transition: transform .15s ease; }
.btn-depliant:hover { background: var(--vert-pale); border-color: var(--vert); color: var(--vert-fonce); }
/* Bouton ouvert : plein, chevron pivoté vers le bas. */
.btn-depliant[aria-expanded="true"] { background: var(--vert); border-color: var(--vert); color: var(--blanc); }
.btn-depliant[aria-expanded="true"] svg { transform: rotate(90deg); }
/* Ligne dépliée : surlignée, soudée à son panneau (le trait entre les deux saute). */
.ligne-ouverte td { background: var(--vert-pale); border-bottom-color: transparent; }
tr.ligne-detail, tbody tr.ligne-detail:hover { background: var(--fond); }
.ligne-detail > td {
    padding: 12px 16px 16px;
    border-left: 3px solid var(--vert);
    border-bottom: 1px solid var(--bordure);
}
.detail-copro { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.detail-copro section {
    background: var(--blanc); border: 1px solid var(--bordure);
    border-radius: var(--radius); padding: 12px 14px;
    /* Tous les volets finissent au même bas ; à l'intérieur, les listes
       longues absorbent l'espace au lieu de laisser un trou sous leur volet. */
    display: flex; flex-direction: column;
}
.detail-copro h3 {
    margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--bordure);
    font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--texte-doux);
}
.detail-copro h3:not(:first-child) { margin-top: 16px; }
.detail-pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 16px; }
.detail-pieces span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* Historique de communication : une entrée = le type (lien vers la trace),
   canal et date en dessous, statut aligné à droite. Défile au-delà de 10aine. */
.detail-envois { list-style: none; margin: 0; padding: 0; }
.detail-envois li { padding: 7px 0; border-bottom: 1px solid var(--bordure); }
/* Même plafond de base (280px) pour l'historique de communication et celui du
   copropriétaire ; la liste peut ensuite s'étendre pour finir au même bas que
   les autres volets, et défile au-delà. */
.detail-copro .detail-envois,
.detail-copro .journal { flex: 1 1 280px; min-height: 0; overflow-y: auto; padding-right: 6px; }
.detail-envois li:last-child { border-bottom: 0; }
.detail-envoi-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-envois a { font-weight: 600; }
/* Un libellé de statut long se replie dans sa pastille au lieu d'écraser le titre. */
.detail-envois .badge { white-space: normal; text-align: center; }
.detail-envois .sous-titre { font-size: 12px; }
.detail-copro .journal li { padding: 6px 0 6px 10px; }
.choix-canal { display: flex; align-items: center; gap: 6px; }
/* ── Checklist de contrôle (aperçu d'une pièce) ──────────── */
.points-vigilance ul { list-style: none; margin: 0; padding: 0; }
.points-vigilance li { padding: 4px 0; }
.points-vigilance label { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.points-vigilance input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
/* Point relu : estompé, la liste se lit comme une checklist qui se vide. */
.points-vigilance input:checked + span { color: var(--texte-doux); text-decoration: line-through; }
/* Déclinaison dans la modale d'aperçu d'une pièce : bandeau compact sous
   l'en-tête, en regard du document affiché. */
/* Panneau latéral de la modale d'aperçu : la checklist en regard du document. */
.apercu-controles {
    width: 300px; flex-shrink: 0; overflow-y: auto;
    padding: 12px 16px; background: var(--blanc);
    border-left: 1px solid var(--bordure); font-size: 13px;
}
.apercu-controles strong { display: block; margin-bottom: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--texte-doux); }
.apercu-controles strong + ul, .apercu-controles p { margin: 0 0 4px; }
/* Un espace entre le bloc identité et la checklist. */
.apercu-controles p + strong { margin-top: 16px; }
.apercu-identite { font-weight: 700; font-size: 14px; color: var(--texte); }

/* Aperçu du message groupé : ce qui va réellement partir, avant l'envoi. */
.apercu-masse {
    margin: 0 16px 12px; padding: 10px 14px;
    background: var(--fond); border: 1px dashed var(--bordure); border-radius: var(--radius);
}
.apercu-masse .contenu-envoi { max-height: 220px; overflow-y: auto; margin: 6px 0 0; }
/* Ligne d'en-tête d'un groupe dans la sélection de message groupé. */
.ligne-groupe td, tbody tr.ligne-groupe:hover { background: var(--fond); }
/* Ligne porte-bouton « voir plus » du journal : pas un événement, pas de liseré. */
.journal li.journal-suite { border-left-color: transparent; border-bottom: 0; padding-bottom: 0; }

/* ── Cartes ──────────────────────────────────────────────── */
.carte { background: var(--blanc); border: 1px solid var(--bordure); border-radius: var(--radius); box-shadow: var(--ombre); margin-bottom: 20px; }
.carte > header { padding: 13px 16px; border-bottom: 1px solid var(--bordure); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.carte > header h2 { margin: 0; }
.carte .corps { padding: 16px; }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
/* Grille dédiée à la fiche dossier : une carte peut s'étendre sur 2 colonnes
   (ex. « AG & travaux »), sans toucher au .grille-2 partagé par les formulaires. */
.grille-fiche { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; grid-auto-flow: dense; }
.grille-fiche .carte-large { grid-column: span 2; }

/* ── Tableaux ────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
th {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--texte-doux); background: #fafbfa; font-weight: 700;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--vert-pale); }
/* Alerte visuelle du dossier (état/date) : liseré coloré en tête de ligne. */
tr.dossier-en-retard > td:first-child { border-left: 3px solid var(--rouge); }
tr.dossier-echeance-proche > td:first-child { border-left: 3px solid var(--orange); }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
td.actions-ligne { text-align: right; white-space: nowrap; }
tfoot th { background: #fafbfa; }
.tableau-vide { padding: 32px 16px; text-align: center; color: var(--texte-doux); }

/* ── Fiches (couples libellé / valeur) ───────────────────── */
/* Colonne de libellés proportionnelle : les cartes de la fiche dossier sont
   étroites, une largeur fixe y tasserait les valeurs. */
.fiche { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; margin: 0; }
.fiche dt { color: var(--texte-doux); }
.fiche dd { margin: 0; }
.vide { color: #a4aeb4; font-style: italic; }
/* Un montant ne se coupe jamais : ni entre le nombre et le €, ni aux milliers. */
.montant { white-space: nowrap; }

/* ── Aide contextuelle : info-bulle native (title) au survol du libellé ── */
.aide { cursor: help; }

/* ── Bandeau CA honoraires (double phasage) ──────────────── */
.ca-bandeau { display: flex; flex-direction: column; gap: 14px; }
.ca-total { display: flex; align-items: baseline; gap: 10px; }
.ca-montant { font-size: 26px; font-weight: 700; color: var(--vert-fonce); line-height: 1; }
.ca-sous { color: var(--texte-doux); font-size: 13px; }
.ca-phases { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.ca-phases > div {
    border: 1px solid var(--bordure); border-radius: var(--radius); padding: 8px 11px; background: var(--blanc);
}
.ca-phases dt { color: var(--texte-doux); font-size: 12px; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.ca-phases dd { margin: 0; font-weight: 600; }
.ca-progression-tete { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.ca-potentiel { color: var(--texte-doux); }
.barre-progression { height: 10px; border-radius: var(--pilule); background: var(--gris-pale); overflow: hidden; }
.barre-progression-jauge {
    height: 100%; background: var(--vert); border-radius: var(--pilule); transition: width .3s ease; min-width: 2px;
}
.barre-progression-jauge.orange { background: var(--orange); }
.barre-progression-jauge.rouge { background: var(--rouge); }
.ca-note { color: var(--texte-doux); font-size: 12px; }

/* ── Limite de communication (dossiers, page de liste) ──────── */
.quotas { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.quota-tete { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.quota-tete span:first-child { font-weight: 600; }

/* ── Blocage cycle de vie (lettre de mission non signée) ──── */
.bandeau-blocage {
    background: var(--rouge-pale); border: 1px solid #f0c9c6; border-radius: var(--radius);
    padding: 10px 12px; margin-bottom: 12px; color: var(--rouge); font-size: 13px;
}
.bandeau-blocage a { color: var(--rouge); font-weight: 600; text-decoration: underline; }
.ligne-phase { color: var(--texte-doux); font-size: 13px; margin-bottom: 10px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 2px 10px; border-radius: var(--pilule);
    font-size: 12px; font-weight: 600; white-space: nowrap;
    background: var(--gris-pale); color: var(--texte-doux);
}
.badge.vert { background: var(--vert-pale); color: var(--vert-fonce); }
.badge.bleu { background: var(--bleu-pale); color: var(--bleu); }
.badge.orange { background: var(--orange-pale); color: var(--orange); }
.badge.rouge { background: var(--rouge-pale); color: var(--rouge); }
.badge.violet { background: var(--violet-pale); color: var(--violet); }
.badge.sarcelle { background: var(--sarcelle-pale); color: var(--sarcelle); }

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
    display: inline-block; padding: 8px 18px; border-radius: var(--pilule);
    border: 1px solid var(--bordure); background: var(--blanc); color: var(--texte);
    font-size: 13px; font-family: inherit; font-weight: 600; cursor: pointer;
    text-decoration: none; line-height: 1.4;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: #f6f8f6; border-color: #cfd8d2; text-decoration: none; }
/* Bouton plein vert du site (« Contact », « Envoyer »). */
.btn.principal { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn.principal:hover { background: var(--vert-fonce); border-color: var(--vert-fonce); color: #fff; }
/* Variante contour verte, également présente sur le site. */
.btn.contour { border-color: var(--vert); color: var(--vert-fonce); background: var(--blanc); }
.btn.contour:hover { background: var(--vert-pale); }
.btn.danger { color: var(--rouge); border-color: #f0c9c6; }
.btn.danger:hover { background: var(--rouge-pale); border-color: #e5b2ae; }
.btn.petit { padding: 4px 12px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Formulaires ─────────────────────────────────────────── */
.champ { margin-bottom: 14px; }
.champ label { display: block; margin-bottom: 4px; color: var(--texte-doux); font-size: 13px; }
.champ input[type=text], .champ input[type=email], .champ input[type=password], .champ input[type=date],
.champ input[type=number], .champ input[type=file], .champ select, .champ textarea {
    width: 100%; padding: 8px 11px; border: 1px solid var(--bordure); border-radius: var(--radius);
    font-family: inherit; font-size: 14px; background: var(--blanc); color: var(--texte);
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
    outline: 2px solid var(--vert); outline-offset: -1px; border-color: var(--vert);
}
.champ textarea { min-height: 72px; resize: vertical; }
.champ .aide { color: var(--texte-doux); font-size: 12px; margin-top: 3px; }
.champ .erreur, .erreur-formulaire { color: var(--rouge); font-size: 12px; margin-top: 3px; }
.champ-inline { display: flex; align-items: center; gap: 8px; }
.champ-inline label { margin: 0; }
.champ input[type=checkbox] { accent-color: var(--vert); width: 15px; height: 15px; }
.grille-champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
fieldset > legend { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--texte-doux); font-weight: 700; padding: 0 0 8px; }
.cases { display: flex; gap: 16px; flex-wrap: wrap; }
.cases label { display: flex; align-items: center; gap: 6px; color: var(--texte); }
.cases input[type=checkbox], .cases input[type=radio] { accent-color: var(--vert); }
.barre-formulaire { display: flex; gap: 8px; align-items: center; padding-top: 4px; }

/* ── Champ référentiel (sélection + création à la volée) ─── */
.champ-avec-action { display: flex; gap: 6px; align-items: stretch; }
.champ-avec-action select { flex: 1; }
.champ-avec-action .btn {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    padding: 0 13px; line-height: 0;
    border-color: var(--vert); color: var(--vert-fonce);
}
.champ-avec-action .btn svg { display: block; }
.champ-avec-action .btn:hover:not(:disabled) { background: var(--vert-pale); }
.champ-avec-action select:disabled { background: var(--gris-pale); color: var(--texte-doux); cursor: not-allowed; }
.champ-referentiel .aide:empty { display: none; }

/* ── Champ recherchable (Tom Select), calqué sur les <select> natifs ─── */
/* Le thème par défaut de Tom Select est plus spécifique que nos règles :
   les propriétés qui doivent matcher le natif sont donc forcées (!important). */
.champ-avec-action .ts-wrapper { flex: 1; margin: 0; }

.ts-wrapper .ts-control {
    min-height: 0 !important;
    padding: 8px 34px 8px 11px !important;
    border: 1px solid var(--bordure) !important;
    border-radius: var(--radius) !important;
    background: var(--blanc) !important;
    color: var(--texte);
    font-size: 14px; line-height: 1.45;
    box-shadow: none !important; cursor: pointer;
}
.ts-wrapper.single.has-items .ts-control { padding-right: 50px !important; } /* place pour × + caret */
.ts-control > input { font-size: 14px; color: var(--texte); }

/* focus identique aux champs natifs */
.ts-wrapper.focus .ts-control {
    outline: 2px solid var(--vert) !important; outline-offset: -1px;
    border-color: var(--vert) !important; box-shadow: none !important;
}
.ts-wrapper.disabled .ts-control {
    background: var(--gris-pale) !important; opacity: 1 !important; color: var(--texte-doux);
}

/* caret à droite, comme un <select> natif */
.ts-wrapper.single .ts-control:after {
    left: auto !important; right: 13px !important; margin-top: -2px !important;
    border-color: var(--texte-doux) transparent transparent !important;
}
/* × pour vider, juste à gauche du caret — seulement quand une valeur est choisie */
.ts-wrapper .clear-button {
    right: 28px !important; opacity: .5 !important; color: var(--texte) !important;
}
.ts-wrapper .clear-button:hover { opacity: 1 !important; }
.ts-wrapper:not(.has-items) .clear-button { display: none !important; }

/* Pendant une recherche active (du texte tapé), on masque la valeur affichée pour
   ne pas superposer item + saisie. En simple focus (sans frappe) ou après
   sélection, la valeur reste visible. La classe est posée par le contrôleur. */
.ts-wrapper.recherche-active.single .ts-control > .item { display: none !important; }
.ts-wrapper.recherche-active .ts-control { cursor: text; }

/* liste déroulante */
.ts-dropdown {
    border: 1px solid var(--bordure) !important; border-radius: var(--radius) !important;
    box-shadow: 0 8px 24px rgba(22, 36, 61, .14) !important; font-size: 14px; margin: 4px 0 0 !important;
}
.ts-dropdown .option { padding: 8px 11px; }
.ts-dropdown .option.active { background: var(--vert-pale) !important; color: var(--vert-fonce) !important; }
/* Option correspondant à la valeur courante : repère persistant (coche + gras),
   distinct du survol, pour voir la sélection en parcourant les propositions. */
.ts-dropdown .option.selected { position: relative; padding-right: 28px; font-weight: 600; }
.ts-dropdown .option.selected::after {
    content: "✓"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--vert);
}
.ts-dropdown .ts-vide { padding: 8px 11px; color: var(--texte-doux); }

/* ── Recherche façon Kendo UI DropDownList (plugin dropdown_input) ──────────
   La recherche vit dans une boîte dédiée en tête du popup ; le contrôle n'est
   pas éditable et se contente d'afficher la valeur choisie (ou le placeholder). */
.ts-dropdown .dropdown-input-wrap { padding: 8px; border-bottom: 1px solid var(--bordure); }
.ts-dropdown .dropdown-input {
    display: block; width: 100%; box-sizing: border-box; margin: 0;
    padding: 8px 11px 8px 33px;
    border: 1px solid var(--bordure) !important; border-radius: var(--radius) !important;
    box-shadow: none !important; background: var(--blanc); color: var(--texte); font-size: 14px;
    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='%238a94a6' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 11px center; background-size: 15px 15px;
}
.ts-dropdown .dropdown-input:focus {
    outline: 2px solid var(--vert); outline-offset: -1px; border-color: var(--vert) !important;
}
/* Étiquette du contrôle : quand rien n'est sélectionné, on affiche le placeholder
   (Tom Select le masque par défaut avec dropdown_input). Non cliquable : le clic
   ouvre le popup via le contrôle. */
.ts-wrapper.plugin-dropdown_input:not(.has-items) .items-placeholder {
    display: block !important; border: 0 !important; box-shadow: none !important;
    background: transparent !important; padding: 0 !important; width: 100%; pointer-events: none;
}
.ts-wrapper.plugin-dropdown_input .items-placeholder::placeholder { color: var(--texte-doux); opacity: 1; }

/* ── Modale ──────────────────────────────────────────────── */
.modale {
    border: 0; border-top: 3px solid var(--vert); border-radius: 12px; padding: 24px;
    width: min(440px, calc(100vw - 32px)); box-shadow: 0 18px 44px rgba(22, 36, 61, .28);
    color: var(--texte); background: var(--blanc);
}
.modale::backdrop { background: rgba(13, 59, 42, .45); }
.modale h2 { margin-bottom: 16px; }

/* Modale d'aperçu d'une pièce : grande surface, en-tête fixe, document défilable.
   Le display n'est posé qu'à l'ouverture : sinon il écrase le « display:none »
   que le navigateur applique à une <dialog> fermée, et la modale reste visible. */
.modale.apercu {
    width: min(920px, calc(100vw - 32px)); height: min(88vh, 900px);
    padding: 0; overflow: hidden;
}
.modale.apercu[open] { display: flex; flex-direction: column; }
.apercu-tete {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--bordure);
}
.apercu-tete h2 {
    margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.apercu-contenu { flex: 1; min-height: 0; display: flex; }
.apercu-corps { flex: 1; min-height: 0; background: var(--fond); overflow: auto; }
.apercu-cadre { width: 100%; height: 100%; border: 0; display: block; }
.apercu-image { display: block; max-width: 100%; margin: 0 auto; }

/* Liste des fichiers d'une pièce dans la grille (recto/verso…). */
/* Fichiers d'une pièce dans la grille : une puce par fichier (recto/verso…). */
.fichiers { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0; }
.fichier-jeton {
    display: inline-flex; align-items: center;
    background: var(--gris-pale); border-radius: var(--pilule); padding: 1px 3px 1px 7px;
}
.fichier-jeton form { display: inline-flex; margin: 0; }
.fichier-nom {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: 0; padding: 0; font: inherit; font-size: 12px;
    color: var(--texte); cursor: pointer; white-space: nowrap;
}
.fichier-nom svg { color: var(--texte-doux); }
.fichier-nom:hover { color: var(--vert-fonce); }
.fichier-nom:hover svg { color: var(--vert-fonce); }
.fichier-retirer {
    background: none; border: 0; cursor: pointer; color: var(--texte-doux);
    font-size: 15px; line-height: 1; padding: 0 3px; margin-left: 2px; border-radius: 50%;
}
.fichier-retirer:hover { color: var(--rouge); background: var(--rouge-pale); }
.fichier-ajout {
    background: none; border: 1px dashed var(--bordure); border-radius: var(--pilule);
    padding: 2px 9px; font-size: 12px; color: var(--texte-doux); cursor: pointer; white-space: nowrap;
}
.fichier-ajout:hover { border-color: var(--vert); color: var(--vert-fonce); background: var(--vert-pale); }
.portail-fichiers { margin-top: 4px; font-size: 12px; color: var(--texte-doux); }

/* Bouton qui se comporte comme un lien (aperçu de pièce), sans style de bouton. */
.lien-bouton {
    background: none; border: 0; padding: 0; margin: 0; font: inherit;
    color: var(--vert-fonce); cursor: pointer; text-decoration: underline;
}
.lien-bouton:hover { color: var(--vert-profond); }
.modale .barre-formulaire { margin-top: 20px; }
.modale .erreur:empty, .erreur-formulaire:empty { display: none; }
.erreur-formulaire {
    background: var(--rouge-pale); border: 1px solid #f2c7c4; color: var(--rouge);
    padding: 8px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px;
}

/* ── Génération de documents ─────────────────────────────── */
/* Saisie à gauche, aperçu du rendu à droite. */
.grille-document { display: grid; grid-template-columns: minmax(320px, 4fr) 5fr; gap: 20px; align-items: start; }
/* L'aperçu est le PDF réel (lecteur natif du navigateur) : le fond gris est
   celui du lecteur, on garde juste le cadre aux couleurs de l'app. */
.apercu-document { width: 100%; height: 82vh; border: 1px solid var(--bordure); border-radius: var(--radius); background: var(--gris-pale); }
@media (max-width: 900px) { .grille-document { grid-template-columns: 1fr; } }

/* Catalogue des documents d'un dossier. */
.liste-documents { list-style: none; }
.liste-documents li {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--bordure);
}
.liste-documents li:last-child { border-bottom: 0; }
.liste-documents .badge { margin-left: 8px; }

/* ── Grille de validation d'import ───────────────────────── */

.grille-import { font-size: 13px; }
.grille-import th { white-space: nowrap; }
.grille-import td { padding: 4px 6px; vertical-align: top; }
.grille-import td.centre { text-align: center; vertical-align: middle; }
.grille-import input[type=text] {
    width: 100%; min-width: 90px; padding: 5px 8px;
    border: 1px solid var(--bordure); border-radius: var(--radius);
    font-family: inherit; font-size: 13px; background: var(--blanc); color: var(--texte);
}
.grille-import input[type=text]:focus { outline: 2px solid var(--vert); outline-offset: -1px; }
/* Champ douteux : surligné en rouge, raison au survol de la cellule. */
.grille-import td.cellule-douteuse input[type=text] {
    border-color: var(--rouge); background: var(--rouge-pale);
}
.grille-import .valeur-brute { color: var(--texte-doux); font-size: 11px; margin-top: 2px; }
/* Ligne écartée de l'import : présente mais estompée. */
.grille-import tr.ligne-ignoree td:not(.centre) { opacity: .45; }
.grille-import tr.ligne-ignoree input[type=text] { text-decoration: line-through; }

/* Matrice des droits (page Utilisateurs). */
.table-scroll { overflow-x: auto; }
.matrice-droits th.centre, .matrice-droits td.centre { text-align: center; width: 160px; }
.matrice-droits .oui { color: var(--vert); font-weight: 700; }
.matrice-droits .non { color: var(--texte-doux); }

/* En-tête de groupe (régions, matrice des droits) dans les tableaux. */
tr.groupe-region th {
    background: var(--vert-pale); color: var(--vert-fonce); text-align: left;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    padding: 6px 12px;
}

/* Liste des postes de travaux sur la fiche dossier. */
.liste-travaux { list-style: none; margin: 0; }
.liste-travaux li {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 6px 16px; flex-wrap: wrap; padding: 7px 0;
    border-bottom: 1px solid var(--bordure);
}
.liste-travaux li:last-child { border-bottom: 0; }
.liste-travaux .travaux-nature { flex: 1 1 12rem; }
.liste-travaux .travaux-detail { display: inline-flex; align-items: baseline; gap: 6px; color: var(--texte-doux); white-space: nowrap; }
.liste-travaux .badge { margin-left: 4px; }

/* Champ verrouillé (forçage réservé à l'administrateur technique). */
.champ input:disabled {
    background: var(--gris-pale); color: var(--texte-doux); cursor: not-allowed;
}

/* ── Filtres ─────────────────────────────────────────────── */
.filtres { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filtres .champ { margin-bottom: 0; }
.filtres input, .filtres select { min-width: 180px; }

/* ── Messages ────────────────────────────────────────────── */
.message { padding: 11px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.message.succes { background: var(--vert-pale); border-color: #b9e2c2; color: var(--vert-fonce); }
.message.erreur { background: var(--rouge-pale); border-color: #f2c7c4; color: var(--rouge); }
.message.info { background: var(--bleu-pale); border-color: #cbdcf0; color: var(--bleu); }
.message.alerte { background: var(--orange-pale); border-color: #f0dab5; color: var(--orange); }
.message ul { margin: 6px 0 0; padding-left: 20px; }
/* Bandeau de conservation : la précision juridique reste lisible dans la couleur du message. */
.message.conservation .sous-titre { color: inherit; opacity: .8; font-size: 12px; }
.message.conservation a { color: inherit; text-decoration: underline; }

/* ── Journal ─────────────────────────────────────────────── */
.journal { list-style: none; margin: 0; padding: 0; }
.journal li { padding: 10px 0 10px 14px; border-bottom: 1px solid var(--bordure); border-left: 2px solid var(--vert-pale); }
.journal li:last-child { border-bottom: 0; }
.journal .quand { color: var(--texte-doux); font-size: 12px; }
.journal .detail { color: var(--texte-doux); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; padding: 12px 16px; color: var(--texte-doux); }
.pagination a, .pagination span.page {
    padding: 4px 11px; border: 1px solid var(--bordure); border-radius: var(--pilule);
    background: var(--blanc); text-decoration: none;
}
.pagination a:hover { background: var(--vert-pale); border-color: var(--vert); text-decoration: none; }
.pagination span.page.courante { background: var(--vert); border-color: var(--vert); color: #fff; font-weight: 600; }
.pagination .compteur { margin-right: auto; }

/* ── Chiffres clés ───────────────────────────────────────── */
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.chiffre {
    background: var(--blanc); border: 1px solid var(--bordure); border-radius: var(--radius);
    padding: 13px 16px; border-top: 3px solid var(--vert);
}
.chiffre .valeur { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--vert-profond); }
.chiffre .libelle { color: var(--texte-doux); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }

/* ── Connexion ───────────────────────────────────────────── */
/* Reprend le bandeau sombre du site, veiné de vert. */
.page-login {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background:
        radial-gradient(1200px 420px at 15% -10%, rgba(42, 162, 62, .30), transparent 60%),
        radial-gradient(900px 380px at 100% 110%, rgba(142, 226, 78, .18), transparent 60%),
        var(--nuit);
}
.page-login .boite {
    background: var(--blanc); border-radius: 14px; padding: 34px; width: 100%; max-width: 384px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .3); border-top: 4px solid var(--vert);
}
.page-login .logo { display: block; width: 58px; height: 58px; margin: 0 auto 12px; }
.page-login .marque {
    font-size: 19px; font-weight: 700; color: var(--nuit); margin-bottom: 6px;
    text-align: center; letter-spacing: .02em; text-transform: uppercase;
}
.page-login .accroche {
    color: var(--texte-doux); margin: 0 0 24px; text-align: center; font-size: 13px;
    /* Filet vert sous la baseline, comme sur la page d'accueil du site. */
    padding-bottom: 16px; position: relative;
}
.page-login .accroche::after {
    content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
    width: 56px; height: 3px; background: var(--vert); border-radius: 2px;
}
.page-login .btn { width: 100%; text-align: center; padding: 10px; }

/* ---- Grille de collecte des pièces (adhérents × pièces attendues) ---- */
.defilable { overflow-x: auto; }
.grille-pieces th { white-space: nowrap; }
.grille-pieces th small { display: block; font-size: 10px; color: var(--texte-doux); font-weight: 500; }
.grille-pieces .colonne-adherent { min-width: 220px; }
.grille-pieces .cellule-piece { font-size: 12px; min-width: 96px; }
.grille-pieces .cellule-piece.sans-objet { color: #a4aeb4; text-align: center; }
.piece-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.piece-actions form { display: inline; }
.btn.petit.valider { color: var(--vert-fonce); border-color: var(--vert); }
.btn.petit.valider:hover { background: var(--vert-pale); }

/* ── Parcours RAC (désendettement) : ligne verte quand la signature est validée ── */
.ligne-signee td { background: var(--vert-pale); }
.envoi-courtier { display: inline-flex; align-items: center; gap: 6px; }
.envoi-courtier select { max-width: 180px; }
/* Le refus se déplie dans la cellule sans quitter la grille. */
.refus summary { list-style: none; cursor: pointer; }
.refus summary::-webkit-details-marker { display: none; }
.refus form { display: flex; gap: 4px; margin-top: 4px; }
.refus input[type="text"] { width: 130px; padding: 3px 8px; font-size: 12px; border: 1px solid var(--bordure); border-radius: 6px; }
.texte-alerte { color: var(--rouge); }

/* ---- Trace d'un envoi ---- */
.contenu-envoi {
    white-space: pre-wrap; font: 13px/1.5 inherit; font-family: inherit;
    background: var(--gris-pale); border: 1px solid var(--bordure);
    border-radius: 8px; padding: 12px 14px; margin: 0;
}
.formulaire { display: flex; flex-direction: column; gap: 12px; }
.formulaire label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.formulaire input[type="text"], .formulaire input[type="email"], .formulaire input[type="tel"],
.formulaire select, .formulaire textarea {
    font: inherit; font-weight: 400; padding: 7px 10px;
    border: 1px solid var(--bordure); border-radius: 8px; background: var(--blanc);
}
.formulaire textarea { resize: vertical; }
.formulaire small { font-weight: 400; }

/* ---- Historique : filtres par catégorie ---- */
.filtres-journal { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.filtre-journal {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border: 1px solid var(--bordure); border-radius: var(--pilule);
    font-size: 12.5px; color: var(--texte-doux); background: var(--blanc); text-decoration: none;
}
.filtre-journal:hover { border-color: #cfd8d2; background: #f6f8f6; text-decoration: none; }
.filtre-journal .compte { font-variant-numeric: tabular-nums; color: var(--texte-doux); font-size: 11.5px; }
.filtre-journal.actif { border-color: var(--nuit); background: var(--nuit); color: var(--blanc); }
.filtre-journal.actif .compte { color: rgba(255, 255, 255, .75); }
/* Le liseré gauche reprend la couleur de la catégorie : l'œil regroupe les
   entrées d'un même sujet sans lire les badges. */
.journal li.journal-cycle { border-left-color: var(--bleu); }
.journal li.journal-fiche { border-left-color: var(--bordure); }
.journal li.journal-recensement { border-left-color: var(--vert); }
.journal li.journal-pieces { border-left-color: var(--orange); }
.journal li.journal-envois { border-left-color: var(--violet); }
.journal li.journal-documents { border-left-color: var(--sarcelle); }

/* ---- Portail public de dépôt des pièces (une colonne, lisible sur mobile) ---- */
.portail { max-width: 640px; margin: 0 auto; }
.portail-entete { display: flex; align-items: center; gap: 14px; margin: 8px 0 20px; }
.portail-entete h1 { font-size: 21px; margin: 0 0 2px; }
.portail-entete .sous-titre { margin: 0; }
.portail-pieces { list-style: none; margin: 0; padding: 0; }
.portail-pieces li {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 12px 0; border-bottom: 1px solid var(--bordure); flex-wrap: wrap;
}
.portail-pieces li:last-child { border-bottom: 0; }
.portail-piece-intitule { flex: 1 1 260px; }
.portail-piece-intitule strong { display: block; margin-bottom: 4px; }
.portail-pied { color: var(--texte-doux); font-size: 12px; margin-top: 18px; text-align: center; }
/* Envoi des pièces pour vérification, sous la liste : c'est lui qui fige le portail. */
.portail-envoi { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--bordure); text-align: center; }
.portail-envoi .sous-titre { margin-bottom: 10px; }
@media (max-width: 520px) {
    .portail-pieces li { align-items: flex-start; }
    .portail-pieces form, .portail-pieces .btn { width: 100%; text-align: center; }
}

/* Lien de dépôt d'un adhérent, sous ses coordonnées dans la grille. */
.lien-portail { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.lien-portail form { display: inline; }
/* Pièces « envoyées » par l'adhérent : badge + déblocage dans la grille. */
.soumission-portail { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.soumission-portail form { display: inline; }
/* Champ révélé par le contrôleur quand le presse-papier a échoué : dernier recours. */
.champ-lien {
    flex: 1 1 100%; min-width: 0; padding: 3px 8px;
    border: 1px solid var(--bordure); border-radius: var(--radius);
    background: var(--fond); color: var(--texte-doux);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
    text-overflow: ellipsis;
}
.champ-lien:focus { color: var(--texte); background: var(--blanc); outline: 2px solid var(--vert-clair); }
