/* =========================================================================
   ESPACE ÉTABLISSEMENT
   ========================================================================= */

.estab-main { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.estab-main > nav .breadcrumb { margin-bottom: 0; }
.estab-main > .page-head { margin-bottom: 0; }
.estab-small { font-size: .9rem; margin: -6px 0 14px; }
.estab-subtitle { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 -8px; font-size: .92rem; color: var(--ink-2); }
.estab-missing { color: var(--danger); font-weight: 600; font-size: .9rem; }
.estab-count { background: var(--warning); color: #fff !important; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }

/* ---------- Bandeau d'identité ---------- */
.estab-identity {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    padding: 28px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-1);
    position: relative;
    overflow: hidden;
}

.estab-identity::before {
    /* une tranche, comme sur les pages de garde */
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: var(--spine-0);
}

.estab-crest {
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    border-radius: 18px;
    background: var(--indigo-50);
    color: var(--indigo);
}

.estab-crest .icon { width: 30px; height: 30px; }

.estab-identity-body { flex: 1; min-width: 240px; }
.estab-greeting { margin: 0 0 2px; font-size: .9rem; color: var(--ink-3); }

.estab-identity h1 {
    margin: 0 0 12px;
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.4rem);
    letter-spacing: -.02em;
    line-height: 1.1;
}

.estab-identity-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    font-size: .9rem;
    color: var(--ink-2);
}

.estab-identity-meta > span:not(.status), .estab-identity-meta > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.estab-identity-meta .icon { width: 16px; height: 16px; color: var(--ink-3); }

/* ---------- À traiter ---------- */
.estab-todo { align-items: center; }
.estab-todo p { flex: 1; }
.estab-todo .btn { flex-shrink: 0; }

/* ---------- Colonnes du tableau de bord ---------- */
.estab-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.estab-side { display: flex; flex-direction: column; gap: 20px; }
.estab-side .panel + .panel { margin-top: 0; }

.estab-table-scroll { position: relative; overflow-x: auto; margin-top: 4px; }
.estab-table-scroll table th:first-child, .estab-table-scroll table td:first-child { padding-left: 24px; }
.estab-table-scroll table th:last-child, .estab-table-scroll table td:last-child { padding-right: 18px; }
.estab-empty-in-panel { margin: 0 24px 24px; }
.estab-empty-in-panel > .icon { width: 44px; height: 44px; padding: 11px; }

.table .person strong { font-size: .92rem; }
.table .person span:not(.avatar) { font-size: .8rem; }
.table td.num .btn .icon { width: 15px; height: 15px; }

tr.estab-row-pending td { background: #FFFCF3; }
tr.estab-row-pending td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

/* Répartition */
.estab-bar {
    display: flex;
    gap: 3px;
    height: 10px;
    margin-bottom: 14px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--line-soft);
}

.estab-bar span.is-pending { background: #E3A23B; }
.estab-bar span.is-approved { background: var(--green); }
.estab-bar span.is-rejected { background: var(--danger); }

.estab-split .list-item { padding: 10px 0; font-size: .93rem; }
.estab-split .list-item:first-child { padding-top: 0; }
.estab-split strong { font-variant-numeric: tabular-nums; }

.estab-key { display: inline-flex; align-items: center; gap: 9px; color: var(--ink-2); }
.estab-key::before { content: ""; width: 9px; height: 9px; border-radius: 3px; }
.estab-key.is-pending::before { background: #E3A23B; }
.estab-key.is-approved::before { background: var(--green); }
.estab-key.is-rejected::before { background: var(--danger); }

/* Actions rapides */
.estab-quick { display: flex; flex-direction: column; gap: 4px; margin: -4px -10px -10px; }

.estab-quick a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 12px;
    color: var(--ink);
}

.estab-quick a:hover { background: var(--canvas); color: var(--ink); }

.estab-quick a > .icon {
    width: 36px;
    height: 36px;
    padding: 8px;
    border-radius: 10px;
    background: var(--green-50);
    color: var(--green);
}

.estab-quick span { display: flex; flex-direction: column; line-height: 1.3; }
.estab-quick strong { font-size: .93rem; }
.estab-quick small { font-size: .8rem; color: var(--ink-3); }

.estab-shelf-section { padding-top: 12px; }
.estab-shelf-section .shelf { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.estab-shelf-section .cover-md { font-size: 13px; }

/* ---------- Demande de vérification ---------- */
.estab-applicant {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.estab-applicant h1 { margin: 0 0 4px; font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); }
.estab-applicant p { margin: 0; }
.estab-applicant > div:nth-child(2) { flex: 1; min-width: 200px; }
.estab-applicant-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: .84rem; }

.estab-split-layout { grid-template-columns: minmax(0, 1fr) 360px; }
.estab-split-layout .stack > .panel + .panel { margin-top: 20px; }

.estab-dl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.estab-dl-grid > div { grid-template-columns: 1fr; gap: 2px; }
.estab-dl-grid > div:nth-child(2) { border-top: 0; padding-top: 0; }

.estab-bio { font-family: var(--font-serif); font-size: 1.12rem; line-height: 1.6; color: var(--ink); }

.estab-comment {
    margin: 0;
    padding: 14px 18px;
    border-left: 4px solid var(--marker);
    background: var(--marker-50);
    border-radius: 0 var(--r-md) var(--r-md) 0;
}

.estab-timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }

.estab-timeline li {
    position: relative;
    padding: 0 0 20px 26px;
    border-left: 2px solid var(--line);
}

.estab-timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.estab-timeline li::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ink-3);
    box-shadow: 0 0 0 3px var(--paper);
}

.estab-timeline li.is-approved::before { background: var(--green); }
.estab-timeline li.is-rejected::before { background: var(--danger); }
.estab-timeline li.is-submitted::before { background: var(--indigo); }

.estab-timeline-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.estab-timeline h3 { margin: 0; font-size: .98rem; }
.estab-timeline time { font-size: .82rem; }
.estab-timeline p { margin: 2px 0 0; font-size: .86rem; }
.estab-timeline-comment { margin-top: 8px; padding: 10px 14px; border-radius: 10px; background: var(--canvas); font-size: .92rem; }

.estab-decision { display: flex; flex-direction: column; gap: 12px; }
.estab-decision .panel + .panel { margin-top: 0; }
.estab-decision-form textarea { min-height: 96px; }
.estab-decision .divider-text { margin: 18px 0; }
.estab-required { color: var(--danger); }

/* ---------- Domaines ---------- */
.estab-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
}

.estab-cat {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-left: 30px;
    overflow: hidden;
}

.estab-cat::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 7px;
    background: var(--spine);
}

.estab-cat + .estab-cat { margin-top: 0; }
.estab-cat.is-inactive { background: var(--canvas); }
.estab-cat.is-inactive::before { background: var(--line); }
.estab-cat.is-inactive h2 { color: var(--ink-2); }

.estab-cat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.estab-cat-head h2 { margin: 0; font-size: 1.12rem; }
.estab-cat-desc { margin: 0 0 12px; font-size: .92rem; color: var(--ink-2); }

.estab-slug {
    align-self: flex-start;
    margin-bottom: 16px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--line-soft);
    color: var(--ink-3);
    font-size: .78rem;
}

.estab-cat-actions, .estab-formation-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

/* ---------- Formations ---------- */
.estab-formation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.estab-formation { display: flex; flex-direction: column; }
.estab-formation + .estab-formation { margin-top: 0; }
.estab-formation-head h2 { margin: 10px 0 8px; font-size: 1.15rem; line-height: 1.25; }
.estab-formation-desc { margin: 0 0 16px; font-size: .92rem; color: var(--ink-2); }

.estab-formation-figures {
    display: flex;
    gap: 28px;
    margin: 0 0 4px;
}

.estab-formation-figures div { display: flex; align-items: baseline; flex-direction: row-reverse; justify-content: flex-end; gap: 6px; }
.estab-formation-figures dd { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.estab-formation-figures dt { font-size: .86rem; color: var(--ink-3); }

.estab-locked { display: inline-flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--ink-3); }
.estab-locked .icon { width: 15px; height: 15px; }

/* ---------- Formulaires ---------- */
.estab-form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 20px;
    align-items: start;
}

.estab-form { max-width: none; }
.estab-form > div:has(> label) { margin-bottom: 18px; }
.estab-check > div { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); }
.estab-check > div:has(input:checked) { border-color: var(--green); background: var(--green-50); }
.estab-check label { margin: 0; }

/* ---------- Profil ---------- */
.estab-profile-grid { align-items: start; }
.estab-profile-grid .panel + .panel { margin-top: 0; }
.estab-profile-grid .stack > * + * { margin-top: 20px; }
.estab-owner strong { font-size: 1rem; }

.estab-doc {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px dashed var(--line);
    border-radius: var(--r-md);
    background: var(--canvas);
}

.estab-doc-icon { display: inline-grid; place-items: center; width: 40px; height: 44px; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); color: var(--ink-2); flex-shrink: 0; }
.estab-doc strong { display: block; font-size: .92rem; }
.estab-doc span:not(.estab-doc-icon) { font-size: .84rem; color: var(--ink-3); word-break: break-all; }

.estab-main > .form-actions { margin-top: 0; }

@media (max-width: 1180px) {
    .estab-columns { grid-template-columns: 1fr; }
    .estab-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
    .estab-split-layout, .estab-form-layout { grid-template-columns: 1fr; }
    .estab-applicant-status { align-items: flex-start; }
}

@media (max-width: 720px) {
    .estab-identity { padding: 22px 20px 22px 26px; gap: 16px; }
    .estab-identity > .btn { width: 100%; }
    .estab-crest { width: 52px; height: 52px; border-radius: 14px; }
    .estab-side { grid-template-columns: 1fr; }
    .estab-dl-grid { grid-template-columns: 1fr; }
    .estab-dl-grid > div:nth-child(2) { border-top: 1px solid var(--line-soft); padding-top: 11px; }
    .estab-todo { flex-wrap: wrap; }
    .estab-todo .btn { width: 100%; }
    .estab-table-scroll table th:first-child, .estab-table-scroll table td:first-child { padding-left: 16px; }
    .estab-empty-in-panel { margin: 0 16px 16px; }
}

.estab-main .stats .stat { display: flex; flex-direction: column; justify-content: space-between; }
.estab-shelf-section .shelf { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) { .estab-shelf-section .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.estab-cat-actions form, .estab-formation-actions form { display: inline-flex; width: auto; margin: 0; }
.estab-cat-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* Case « active » : case + libellé sur une ligne, aide en dessous */
.estab-check > div {
    display: grid !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 4px 10px;
}
.estab-check > div > input[type="checkbox"] { grid-column: 1; grid-row: 1; order: 0; }
.estab-check > div > label { grid-column: 2; grid-row: 1; order: 0; font-weight: 600; }
.estab-check > div > .help-text, .estab-check > div > .form-help { grid-column: 1 / -1; grid-row: 2; margin: 2px 0 0 28px; }
@media (max-width: 720px) {
    .estab-identity { flex-direction: column; align-items: flex-start; }
    .estab-identity-body { min-width: 0; width: 100%; }
}
