/* Espace interne ---------------------------------------------------------- */
.page-ei .ei-shell { width: 100%; max-width: 1680px; margin: 0 auto; padding: 0 clamp(14px, 2.4vw, 32px); }
.ei-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.ei-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ei-btn { padding: 9px 16px; font-size: 14px; }
.ei-btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--white); }
.ei-link { border: 0; background: none; color: inherit; font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; opacity: .85; }
.ei-user { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; background: rgba(255,255,255,.08); color: inherit; font: inherit; font-size: 14px; cursor: pointer; }
.ei-user::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5CC98B; }
.ei-locked { text-align: center; padding: 40px 0; }
.ei-locked p { margin-bottom: 18px; font-size: 18px; }
.ei-loading { padding: 40px 0; color: var(--slate); }
.ei-app { padding: 22px 0 60px; color: var(--navy); font-size: 14px; }
.ei-app button { font: inherit; }

.ei-banner { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-s); font-size: 14px; }
.ei-banner--edit { background: #FFF4DC; border: 1px solid #F0D49A; }
.ei-banner--warn { background: #FDECEA; border: 1px solid #F3B7B2; color: var(--danger); }
.ei-banner--info { background: #EAF5F9; border: 1px solid #BFE0EC; }

.ei-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.ei-tab { padding: 10px 16px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--slate); font-weight: 700; cursor: pointer; }
.ei-tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--lagoon); }
.ei-tab .ei-count { margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--mist); font-size: 12px; }

.ei-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; }
.ei-toolbar .ei-grow { flex: 1 1 auto; }
.ei-input, .ei-select, .ei-textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--navy); font: inherit; font-size: 14px; }
.ei-input:focus, .ei-select:focus, .ei-textarea:focus { outline: 2px solid var(--lagoon); outline-offset: 0; }
.ei-search { width: min(320px, 100%); }
.ei-textarea { width: 100%; min-height: 70px; resize: vertical; }
.ei-tbtn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); color: var(--navy); cursor: pointer; font-size: 14px; }
.ei-tbtn:hover { border-color: var(--lagoon); }
.ei-tbtn--primary { background: var(--navy); border-color: var(--navy); color: var(--white); }
.ei-tbtn--primary:hover { background: var(--navy-land); }
.ei-tbtn--danger { color: var(--danger); }
.ei-tbtn--small { padding: 4px 8px; font-size: 13px; }
.ei-tbtn[disabled] { opacity: .5; cursor: default; }
.ei-meta { color: var(--slate); font-size: 13px; }

.ei-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.ei-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: #EAF5F9; font-size: 13px; }
.ei-chip button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(21,46,69,.1); color: var(--navy); cursor: pointer; line-height: 1; }

.ei-hl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 10px; padding: 9px 12px; border-radius: var(--radius-s); background: #E3F2E8; border: 1px solid #9FD3B2; }
.ei-hl-bar strong { font-weight: 700; }

/* Tableau */
.ei-table-wrap { position: relative; max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--white); }
.ei-table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
.ei-table th, .ei-table td { border-right: 1px solid #E6ECF0; border-bottom: 1px solid #E6ECF0; }
.ei-table thead th { position: sticky; top: 0; z-index: 2; padding: 0; background: #152E45; color: var(--white); text-align: left; vertical-align: top; }
.ei-table thead th.is-admin { background: #2C5F7C; }
.ei-table th:first-child, .ei-table td:first-child { position: sticky; left: 0; z-index: 1; }
.ei-table thead th:first-child { z-index: 3; }
.ei-table td:first-child { background: var(--white); font-weight: 700; box-shadow: 1px 0 0 #D5DCE3; }
.ei-th { display: flex; align-items: stretch; min-height: 44px; }
.ei-th-sort { flex: 1; display: flex; align-items: center; gap: 4px; padding: 6px 4px 6px 8px; border: 0; background: none; color: inherit; font-weight: 700; font-size: 12px; text-align: left; line-height: 1.25; cursor: pointer; }
.ei-th-sort .ei-arrow { font-size: 10px; opacity: .9; white-space: nowrap; }
.ei-th-menu { width: 26px; border: 0; background: none; color: rgba(255,255,255,.75); cursor: pointer; font-size: 13px; }
.ei-th-menu:hover, .ei-th-menu.is-active { color: var(--gold-light); }
.ei-th-menu.is-active::after { content: "●"; font-size: 8px; vertical-align: super; }
.ei-table td { padding: 6px 8px; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; background-clip: padding-box; }
.ei-table td.is-num { text-align: center; }
.ei-table td.is-flag { background: #FFD580; cursor: help; position: relative; }
.ei-table td.is-flag::after { content: ""; position: absolute; top: 0; right: 0; border-width: 0 7px 7px 0; border-style: solid; border-color: transparent #C0392B transparent transparent; }
.ei-table td:first-child.is-flag { background: #FFD580; }
.ei-table tbody tr:hover td { background-color: #F3F8FB; }
.ei-table tbody tr:hover td.is-flag { background-color: #FFCB66; }
.ei-table tbody tr.is-hl td { background-color: #DFF3E6; }
.ei-table tbody tr.is-hl td:first-child { box-shadow: inset 4px 0 0 #2E9E5B, 1px 0 0 #D5DCE3; }
.ei-table tbody tr.is-hl td.is-flag { background-color: #FFD580; }
.ei-table tbody tr.is-dim td { opacity: .45; }
.ei-editing .ei-table td { cursor: text; }
.ei-editing .ei-table td:hover { outline: 2px solid var(--lagoon); outline-offset: -2px; }
.ei-empty { padding: 30px; text-align: center; color: var(--slate); }

/* Statistiques */
.ei-stats-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; margin: 34px 0 12px; }
.ei-stats-head h2 { font-size: 24px; }
.ei-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 16px; align-items: start; }
.ei-card { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--white); overflow: hidden; }
.ei-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; background: #DCEEF4; }
.ei-card-head h3 { font-size: 15px; margin: 0; }
.ei-card-tools { display: flex; gap: 4px; }
.ei-stat { width: 100%; border-collapse: collapse; font-size: 13px; }
.ei-stat th { padding: 6px 10px; text-align: right; color: var(--slate); font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
.ei-stat th:first-child { text-align: left; }
.ei-stat td { padding: 5px 10px; border-bottom: 1px solid #EEF2F5; text-align: right; }
.ei-stat td:first-child { text-align: left; }
.ei-stat tr.is-indent td:first-child { padding-left: 26px; color: var(--slate); }
.ei-num { min-width: 40px; padding: 2px 8px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--lagoon-ink); font-weight: 700; text-decoration: underline dotted; cursor: pointer; }
.ei-num:hover { border-color: var(--lagoon); background: #EAF5F9; }
.ei-num.is-active { background: #2E9E5B; color: var(--white); text-decoration: none; }
.ei-num.is-static { color: var(--navy); text-decoration: none; cursor: default; }
.ei-pct { color: var(--slate); }

/* Incohérences, journal, sauvegardes */
.ei-list { width: 100%; border-collapse: collapse; background: var(--white); font-size: 13px; }
.ei-list th { position: sticky; top: 0; padding: 8px; background: #152E45; color: var(--white); text-align: left; font-size: 12px; }
.ei-list td { padding: 7px 8px; border-bottom: 1px solid #E6ECF0; vertical-align: top; }
.ei-list tr:hover td { background: #F7FAFC; }
.ei-list-wrap { max-height: 75vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.ei-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ei-badge--todo { background: #FFD580; }
.ei-badge--done { background: #D7F0E0; color: #1E6B3D; }
.ei-linkbtn { border: 0; background: none; padding: 0; color: var(--lagoon-ink); font-weight: 700; text-align: left; text-decoration: underline; cursor: pointer; }

/* Fenêtres et menus flottants */
.ei-pop { position: absolute; z-index: 60; width: 340px; max-width: calc(100vw - 20px); max-height: 72vh; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--white); color: var(--navy); box-shadow: 0 16px 44px rgba(8,24,38,.22); font-size: 14px; }
.ei-pop h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--slate); }
.ei-pop section + section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.ei-pop .ei-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ei-pop label { display: block; margin: 8px 0 4px; font-size: 13px; font-weight: 700; color: var(--slate); }
.ei-pop .ei-input, .ei-pop .ei-select { width: 100%; }
.ei-checks { max-height: 220px; overflow: auto; margin: 6px 0; padding: 4px; border: 1px solid var(--line); border-radius: 8px; }
.ei-checks label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 3px 4px; font-weight: 400; color: var(--navy); cursor: pointer; }
.ei-checks label span:last-child { margin-left: auto; color: var(--slate); font-size: 12px; }
/* Menu « Colonnes » : ordre par glisser-déposer (poignée ⠿, visible seulement pour les personnes autorisées) */
.ei-colhint { margin: 8px 0 0; font-size: 12px; line-height: 1.4; color: var(--slate); }
.ei-colitem { display: flex; align-items: center; gap: 2px; border-radius: 6px; }
.ei-colitem label { flex: 1; min-width: 0; }
.ei-colitem label span:last-child { min-width: 0; margin-left: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--navy); font-size: 13px; }
.ei-collist.can-order .ei-colitem label { padding-left: 0; }
.ei-drag { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 26px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--slate); font-size: 16px; line-height: 1; cursor: grab; touch-action: none; opacity: .5; }
.ei-colitem:hover .ei-drag, .ei-drag:focus-visible { opacity: 1; background: var(--mist); color: var(--lagoon-ink); }
.ei-drag:focus-visible { outline: 2px solid var(--lagoon); outline-offset: -2px; }
.ei-colitem.is-dragging { position: relative; z-index: 1; background: var(--white); box-shadow: 0 4px 14px rgba(8,24,38,.18); outline: 1px solid var(--lagoon); }
.ei-colitem.is-dragging .ei-drag { opacity: 1; color: var(--lagoon-ink); }
body.ei-sorting, body.ei-sorting * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.ei-collist.is-busy { opacity: .6; pointer-events: none; }
.ei-check { display: flex !important; align-items: center; gap: 8px; font-weight: 400 !important; color: var(--navy) !important; cursor: pointer; }
.ei-pop-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.ei-comment { padding: 8px 10px; border-radius: 8px; background: #FFF4DC; white-space: pre-wrap; }

.ei-dialog { width: min(820px, calc(100% - 24px)); }
.ei-dialog h3 { margin: 0 0 12px; font-size: 20px; }
.ei-dialog label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 700; color: var(--slate); }
.ei-dialog .ei-input, .ei-dialog .ei-select { width: 100%; }
.ei-line-box { margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--mist); }
.ei-cond { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 6px; margin: 6px 0; }
.ei-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ei-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 14px; }
.ei-names button { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--mist); color: var(--navy); font-weight: 700; cursor: pointer; }
.ei-names button:hover { border-color: var(--lagoon); background: var(--white); }

.ei-toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 10px; background: var(--navy); color: var(--white); font-size: 14px; box-shadow: 0 10px 30px rgba(8,24,38,.3); }
.ei-toast--err { background: var(--danger); }

@media (max-width: 700px) {
    .ei-stats { grid-template-columns: 1fr; }
    .ei-cond { grid-template-columns: 1fr 1fr; }
    .ei-grid2 { grid-template-columns: 1fr; }
}

/* Corrections d'affichage */
.ei-table td.is-flag:first-child { position: sticky; left: 0; }
.ei-table-wrap { scroll-margin-top: 110px; }
.ei-head .ei-btn { border: 1px solid rgba(255,255,255,.45); border-radius: 999px; background: transparent; color: var(--white); }
.ei-head .ei-btn:hover { background: rgba(255,255,255,.12); }
.ei-head .ei-btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); }

/* 13/11 : en-tête du site non fixé sur cette page, tableau plus haut et lignes plus compactes, colonne Source */
.page-ei .site-header { position: absolute; }
.ei-table-wrap { max-height: calc(100vh - 110px); scroll-margin-top: 16px; }
.ei-table td { padding: 4px 8px; line-height: 1.45; }
.ei-th { min-height: 40px; }
.ei-th-sort { padding: 5px 4px 5px 8px; }
.ei-src { max-width: 220px; overflow-wrap: anywhere; }
.ei-src .ei-linkbtn { font-weight: 700; }
.ei-pop a.ei-tbtn { justify-content: center; text-decoration: none; }

/* Hauteur du tableau adaptée à l'écran (≈ 18 lignes sur un portable 13 pouces) */
.ei-table-wrap {
    max-height: max(300px, calc(100vh - 175px));
    max-height: max(300px, calc(100dvh - 175px));
}
@media (max-width: 900px) {
    .ei-table-wrap { max-height: max(280px, calc(100dvh - 150px)); }
    .ei-stats { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .ei-app { padding-top: 14px; }
    .ei-table-wrap { max-height: max(260px, calc(100dvh - 120px)); }
    .ei-table col:first-child { width: 150px !important; }
    .ei-table td { max-width: 260px; }
    .ei-head-actions { width: 100%; }
    .ei-head-actions .ei-btn { flex: 1 1 auto; }
    .ei-toolbar .ei-search { width: 100%; }
    .ei-tabs { flex-wrap: nowrap; overflow-x: auto; }
    .ei-tab { white-space: nowrap; padding: 10px 12px; }
    .ei-pop { width: calc(100vw - 20px) !important; }
}

/* Montants (€) */
.ei-table td.is-money { text-align: right; font-variant-numeric: tabular-nums; }
.ei-table td.is-computed { background: #F3F7FA; font-weight: 700; color: var(--navy); }
