.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.simple-list-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    background: #fff;
    margin-top: 12px;
}

.simple-list-table th,
.simple-list-table td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
    white-space: nowrap;
}

.simple-list-table thead th {
    background: #f8fafc;
    color: var(--c-primary);
    font-weight: 700;
}

/* Colonne à contenu long (libellé de document, intitulé d'activité…) : autorise le
   retour à la ligne, sinon la cellule impose sa largeur et la liste part en
   défilement horizontal. À poser sur le th ET les td de la colonne. */
.simple-list-table th.col-wrap,
.simple-list-table td.col-wrap { white-space: normal; }

/* Colonnes fixes */
.simple-list-table th.col-actions { width: 90px; }
.simple-list-table th.col-date    { width: 110px; }
.simple-list-table th.col-age     { width: 70px; }
.simple-list-table th.col-year    { width: 90px; }
.simple-list-table th.col-status  { width: 90px; }
.simple-list-table th.col-code    { width: 120px; }
.simple-list-table th.col-bool    { width: 80px; }
.simple-list-table th.col-phone   { width: 120px; }
.simple-list-table th.col-email   { width: 220px; }
.simple-list-table th.col-unit    { width: 180px; }

/* Colonne principale = prend le reste */
.simple-list-table .col-main {
    width: auto;
    white-space: normal;
}

/* Hover */
.simple-list-table tbody tr:hover {
    background: #f8fbff;
}

.simple-list-table th.col-actions,
.simple-list-table td.col-actions { width: 170px; }
.simple-list-table td.col-actions .btn { margin-right: 6px; }

/* Passe 5 : tableaux plus compacts et sans dépassement de carte */
.admin-family-table {
    table-layout: fixed;
    width: 100%;
}
.admin-family-table th,
.admin-family-table td {
    white-space: normal;
    overflow-wrap: anywhere;
}
.admin-family-table .col-family-name { width: 28%; }
.admin-family-table .col-family-city { width: 20%; }
.admin-family-table .col-other-groups { width: 85px; }

.btn-icon {
    width: 28px;
    min-width: 28px;
    padding: 6px 0;
    text-align: center;
    line-height: 1;
    font-weight: 700;
}
.pending-marker,
label.required::after {
    color: #e11d48;
    font-weight: 700;
}
.pending-marker {
    margin-left: 4px;
    font-size: 1.2em;
    cursor: help;
}
.simple-list-table th.col-actions,
.simple-list-table td.col-actions { width: 135px; }

/* Passe 6 : actions compactes, statut préinscription et tableau familles admin */
.btn-action-column {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box; /* <a> et <button> à dimensions identiques (sinon le lien est plus grand) */
    width: 30px;
    min-width: 30px;
    height: 30px;
    padding: 0;
    margin-right: 4px;
    border: 1px solid var(--c-primary);
    border-radius: var(--radius-sm);
    background: #dbeafe;
    color: var(--c-primary);
    font-size: 15px;
    line-height: 1;
    text-decoration: none;
    vertical-align: middle;
}

.btn-action-column:hover {
    background: #bfdbfe;
}

.btn-action-delete {
    background: var(--c-danger-bg);
    border-color: var(--c-danger);
    color: var(--c-danger);
}

.btn-action-delete:hover {
    background: var(--c-danger-bg-hover);
}

.pending-status {
    color: #e11d48;
    font-weight: 700;
    cursor: default;
}

.admin-family-table {
    table-layout: fixed;
    width: 100%;
}
.admin-family-table col.col-family-name { width: 30%; }
.admin-family-table col.col-family-city { width: 22%; }
.admin-family-table col.col-primary-group { width: 16%; }
.admin-family-table col.col-other-groups { width: 10%; }
.admin-family-table col.col-children-count { width: 6%; }
.admin-family-table col.col-status { width: 8%; }
.admin-family-table col.col-open-action { width: 8%; }
.admin-family-table th,
.admin-family-table td {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}
.admin-family-table td:last-child,
.admin-family-table th:last-child {
    text-align: right;
}
.simple-list-table th.col-actions,
.simple-list-table td.col-actions {
    width: 80px;
    min-width: 80px;
}

/* Passe 8 */
.family-detail-table th.col-actions,
.family-detail-table td.col-actions,
.simple-list-table th.col-actions,
.simple-list-table td.col-actions {
    width: 80px;
    min-width: 80px;
    text-align: right;
    white-space: nowrap;
}

.btn-action-column {
    margin-right: 0;
    margin-left: 3px;
    border-right-width: 1px;
}

.btn-action-disabled,
.btn-action-disabled:hover {
    background: var(--c-disabled-bg) !important;
    border-color: var(--c-disabled-bg) !important;
    color: var(--c-disabled-text) !important;
    cursor: not-allowed;
}

.row-inactive td {
    color: var(--c-neutral);
    background: #f8fafc;
}

.status-preinscription {
    color: #e11d48;
    font-weight: 700;
}

.pending-status {
    color: inherit;
    font-weight: normal;
    font-size: 0.92em;
}

.admin-family-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: 16px;
    align-items: end;
    margin: 12px 0;
}
.admin-family-toolbar.single {
    grid-template-columns: 1fr;
}
.admin-family-toolbar .field {
    margin-bottom: 0;
}
/* Barre d'outils d'une liste : à gauche les filtres qui BORNENT la liste (formulaire
   GET, rechargement), à droite la recherche INSTANTANÉE sur les lignes affichées.
   La recherche est volontairement hors du formulaire : elle n'a rien à y soumettre,
   et la touche Entrée ne doit pas recharger la page. */
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 12px 0 18px;
}
.list-toolbar__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
}
.list-toolbar__search {
    flex: 1 1 260px;
    min-width: 220px;
}
.list-toolbar__search input { width: 100%; }

.sortable-table th[data-sort] {
    cursor: pointer;
    user-select: none;
}
.sortable-table th[data-sort]::after {
    content: ' ⇅';
    color: var(--c-neutral);
    font-size: 0.85em;
}
.admin-family-table col.col-family-name { width: 34%; }
.admin-family-table col.col-family-city { width: 24%; }
.admin-family-table col.col-primary-group { width: 16%; }
.admin-family-table col.col-other-groups { width: 9%; }
.admin-family-table col.col-children-count { width: 5%; }
.admin-family-table col.col-status { width: 6%; }
.admin-family-table col.col-open-action { width: 6%; }

/* Passe 9 : toolbar liste familles admin sans bouton, pleine largeur équilibrée */
.admin-family-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 340px) minmax(320px, 1fr);
    gap: 16px;
    align-items: end;
    margin: 12px 0 18px;
}
.admin-family-toolbar .admin-family-group-filter select,
.admin-family-toolbar .admin-family-search input {
    width: 100%;
}
.admin-family-table col.col-family-name { width: 36%; }
.admin-family-table col.col-family-city { width: 24%; }
.admin-family-table col.col-primary-group { width: 15%; }
.admin-family-table col.col-other-groups { width: 9%; }
.admin-family-table col.col-children-count { width: 5%; }
.admin-family-table col.col-status { width: 6%; }
.admin-family-table col.col-open-action { width: 5%; }

/* Passe 11 */
.btn-action-view { background:#dbeafe; border-color:var(--c-primary); color:var(--c-primary); }
.btn-action-view:hover { background:#bfdbfe; }
.btn-action-validate { background:#dcfce7; border-color:#166534; color:#166534; }
.btn-action-validate:hover { background:#bbf7d0; }
/* Édition (crayon) : ambre, distinct de view/validate/delete. */
.btn-action-edit { background:#fef9c3; border-color:#a16207; color:#a16207; }
.btn-action-edit:hover { background:#fef08a; }
.family-detail-table.hide-status .col-status,
.family-detail-table.hide-status td.col-status { display:none; }
.form-field-error input, .form-field-error select, .form-field-error textarea { border-color:#dc2626 !important; background:#fff1f2 !important; }
.field-error-message { color:var(--c-danger); font-size:0.88em; margin-top:4px; }
.family-limited-warning { border:1px solid #f97316; background:#fff7ed; color:#9a3412; padding:10px 12px; border-radius: var(--radius-md); margin:10px 0; }

/* Passe 12 : corrections tableau familles admin */
.admin-family-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 340px) minmax(300px, 1fr);
    gap: 16px;
    align-items: end;
    width: 100%;
}
.admin-family-table {
    table-layout: fixed;
    width: 100%;
}
.admin-family-table col.col-family-name { width: 30%; }
.admin-family-table col.col-family-city { width: 22%; }
.admin-family-table col.col-primary-group { width: 14%; }
.admin-family-table col.col-other-groups { width: 10%; }
.admin-family-table col.col-children-count { width: 6%; }
.admin-family-table col.col-status { width: 8%; }
.admin-family-table col.col-open-action { width: 10%; }
.admin-family-table th,
.admin-family-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal;
    word-break: normal;
}
.admin-family-table td.col-actions,
.admin-family-table th.col-actions {
    width: auto;
    min-width: 0;
    white-space: nowrap;
    text-align: right;
    overflow: visible;
    text-overflow: clip;
}


/* Passe 13 : corrections finales tableau familles + alertes limitées */
.family-limited-warning {
    display: inline-block;
    padding: 6px 10px;
    line-height: 1.25;
}
.admin-family-table {
    table-layout: fixed;
    width: 100%;
    font-size: 0.95rem;
}
.admin-family-table col.col-family-name { width: auto; }
.admin-family-table col.col-family-city { width: 20%; }
.admin-family-table col.col-primary-group { width: 14%; }
.admin-family-table col.col-other-groups { width: 78px; }
.admin-family-table col.col-children-count { width: 58px; }
.admin-family-table col.col-status { width: 72px; }
.admin-family-table col.col-open-action { width: 88px; }
.admin-family-table th,
.admin-family-table td {
    padding: 9px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-family-table td.col-actions,
.admin-family-table th.col-actions {
    width: 88px;
    min-width: 88px;
    max-width: 88px;
    white-space: nowrap;
    overflow: visible;
    text-align: right;
}
.admin-family-table td.col-actions .btn-action-column {
    margin-left: 2px;
}


/* Passe 14 : ajustements tableau familles et familles inactives */
.admin-family-table {
    table-layout: fixed;
    width: 100%;
}
.admin-family-table col.col-family-name { width: auto; }
.admin-family-table col.col-family-city { width: 20%; }
.admin-family-table col.col-primary-group,
.admin-family-table col.col-other-groups,
.admin-family-table col.col-children-count {
    width: 110px;
    min-width: 110px;
    max-width: 110px;
}
.admin-family-table col.col-status { width: 74px; }
.admin-family-table col.col-open-action { width: 94px; }
.admin-family-table td:nth-child(3),
.admin-family-table td:nth-child(4),
.admin-family-table td:nth-child(5),
.admin-family-table th:nth-child(3),
.admin-family-table th:nth-child(4),
.admin-family-table th:nth-child(5) {
    text-align: center;
}
.admin-family-table td.col-actions,
.admin-family-table th.col-actions {
    width: 94px;
    min-width: 94px;
    max-width: 94px;
    text-align: right;
    white-space: nowrap;
    overflow: visible;
}
.admin-family-table tr.row-inactive td {
    background: #f3f4f6;
    color: var(--c-ghost-text);
}
.admin-family-table tr.row-inactive td:first-child {
    border-left: 4px solid var(--c-ghost-border);
}

/* Passe 16 : dernière règle active pour la liste des familles */
.admin-family-table {
    table-layout: fixed;
    width: 100%;
}
.admin-family-table col.col-family-name { width: auto; }
.admin-family-table col.col-family-city { width: 18%; }
.admin-family-table col.col-primary-group,
.admin-family-table col.col-other-groups,
.admin-family-table col.col-children-count {
    width: 100px;
}
.admin-family-table col.col-status { width: 78px; }
.admin-family-table col.col-open-action { width: 126px; }
.admin-family-table td:nth-child(3),
.admin-family-table td:nth-child(4),
.admin-family-table td:nth-child(5),
.admin-family-table th:nth-child(3),
.admin-family-table th:nth-child(4),
.admin-family-table th:nth-child(5) {
    text-align: center;
}
.admin-family-table td.col-actions,
.admin-family-table th.col-actions {
    width: 126px;
    min-width: 126px;
    max-width: 126px;
    white-space: nowrap;
    overflow: hidden;
    text-align: right;
}
.admin-family-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    width: 100%;
    min-width: 0;
}
.admin-family-actions .inline-action-form,
.admin-family-actions .btn-action-column {
    margin: 0;
}
.page-title-row h1 {
    margin-bottom: 0;
}

/* Vue d'ensemble Groupes & unités : tableau groupes/unités avec effectifs. */
.section-subheader { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.section-subheader h2 { margin: 0; }
.section-subheader .subheader-right { margin-left: auto; display: flex; align-items: center; gap: 13px; }
.groups-overview th.num, .groups-overview td.num { text-align: right; white-space: nowrap; width: 72px; }
.groups-overview td.col-actions { text-align: right; width: 48px; }
.groups-overview tr.grp-head td { background: var(--c-ghost-hover-bg); border-top: 2px solid var(--c-ghost-border); }
.groups-overview td.unit-name { padding-left: 28px; position: relative; }
.groups-overview td.unit-name::before { content: "↳"; position: absolute; left: 12px; color: #94a3b8; }
.groups-overview td code { font-size: 0.85em; color: var(--c-ghost-text); }
.branch-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: middle; margin-right: 5px; }
.branch-jaune { background: #eab308; }
.branch-vert { background: #16a34a; }
.branch-rouge { background: #dc2626; }
.side-filter-bar { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0; }
.side-filter-opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.side-filter-opt input { margin: 0; }

/* Lignes « anciens » : jeunes ou familles sans rattachement sur l'année courante,
   affichés seulement quand la liste est élargie à l'historique. Fond ambré discret
   + liseré, pour les distinguer d'un coup d'œil sans les reléguer (leur dossier
   reste pleinement utilisable). Prime sur .row-inactive, qui peut coexister. */
.simple-list-table tr.row-former td,
.admin-family-table tr.row-former td {
    background: #fdf3dd;
    color: #4b5563;
}
.simple-list-table tr.row-former td:first-child,
.admin-family-table tr.row-former td:first-child {
    border-left: 4px solid #e0942f;
}

/* Colonne de tête portant la roue crantée des colonnes affichées : largeur du
   seul picto, cellules vides sur les lignes. */
.simple-list-table th.col-table-cog,
.simple-list-table td.col-table-cog { width: 36px; padding-left: 6px; padding-right: 0; }
