/* ═══ GED documents : arbre par service, grille de pièces, menus contextuels ═══ */
.page-ged .bp-tag.violet { background: color-mix(in srgb, #7c4ddb 14%, var(--surface)); color: #6a3fc4; }
.page-ged .bp-tag svg, .ged-coffre svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.ged-coffre { display: inline-flex; align-items: center; gap: 8px; }
.ged-tuiles { margin-bottom: 16px; }

.ged-corps { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }

/* Arbre */
.ged-arbre { position: sticky; top: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 40px); border: 1px solid var(--trait); border-radius: 18px; background: var(--surface); box-shadow: var(--ombre); overflow: hidden; }
.ged-arbre-tete { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid var(--trait); }
.ged-arbre-tete b { font: 800 13px var(--police); letter-spacing: .08em; text-transform: uppercase; color: var(--encre-2); }
.ged-arbre-liste { flex: 1; overflow-y: auto; padding: 10px; }
.ged-separateur { padding: 14px 10px 6px; font: 800 11px var(--police); letter-spacing: .1em; text-transform: uppercase; color: var(--encre-3); }
.ged-noeud { position: relative; display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 8px 4px calc(8px + var(--prof, 0) * 18px); border-radius: 10px; color: var(--encre); cursor: pointer; outline: none; }
.ged-noeud:hover { background: var(--surface-2); }
.ged-noeud:focus-visible { box-shadow: inset 0 0 0 2px var(--primaire); }
.ged-noeud.actif { background: color-mix(in srgb, var(--c, var(--primaire)) 12%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--primaire)) 40%, transparent); font-weight: 700; }
.ged-plier { flex: 0 0 22px; width: 22px; height: 22px; display: grid; place-items: center; border: 0; padding: 0; background: none; color: var(--encre-3); cursor: pointer; border-radius: 6px; }
.ged-plier:hover { background: var(--surface-3); }
.ged-plier .bp-ico { width: 15px; height: 15px; }
.ged-noeud-ico { display: grid; place-items: center; font-style: normal; color: var(--c, var(--primaire)); }
.ged-noeud-ico .bp-ico { width: 19px; height: 19px; }
.ged-nom { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; }
.ged-verrou { display: grid; color: var(--encre-3); }
.ged-verrou .bp-ico { width: 14px; height: 14px; }
.ged-compte { min-width: 24px; padding: 1px 8px; border-radius: 999px; background: var(--surface-3); color: var(--encre-2); font: 700 12px var(--police); text-align: center; }
.ged-noeud.actif .ged-compte { background: color-mix(in srgb, var(--c, var(--primaire)) 20%, var(--surface)); }
.ged-plus { display: none; width: 26px; height: 26px; place-items: center; border: 0; padding: 0; border-radius: 7px; background: none; color: var(--encre-3); cursor: pointer; }
.ged-plus .bp-ico { width: 16px; height: 16px; }
.ged-noeud:hover .ged-plus, .ged-noeud:focus-within .ged-plus, .ged-plus.visible { display: grid; }
.ged-plus:hover { background: var(--surface-3); color: var(--encre); }
.ged-vide-arbre { margin: 8px 10px; color: var(--encre-3); font-size: 13px; }
.ged-bascule { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--trait); font-weight: 700; cursor: pointer; }
.ged-bascule input { position: absolute; opacity: 0; pointer-events: none; }
.ged-bascule span { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--surface-3); transition: background .2s; }
.ged-bascule span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.ged-bascule input:checked + span { background: var(--primaire); }
.ged-bascule input:checked + span::after { transform: translateX(20px); }
.ged-bascule input:focus-visible + span { box-shadow: 0 0 0 3px var(--primaire-pale); }

/* Barre d'outils */
.ged-outils { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.page-ged .ged-outils select { flex: 0 1 auto; width: auto; max-width: 220px; min-height: 44px; margin: 0; padding: 0 34px 0 12px; border: 1px solid var(--trait); border-radius: 12px; background-color: var(--surface); color: var(--encre); font: 500 14px var(--police); }
.page-ged .ged-recherche { flex: 1 1 280px; display: flex; flex-direction: row; align-items: center; gap: 8px; min-height: 44px; margin: 0; padding: 0 14px; border: 1px solid var(--trait); border-radius: 12px; background: var(--surface); }
.page-ged .ged-recherche:focus-within { border-color: var(--primaire); box-shadow: 0 0 0 3px var(--primaire-pale); }
.ged-recherche .bp-ico { flex: 0 0 18px; width: 18px; height: 18px; color: var(--encre-3); }
.page-ged .ged-recherche input:focus, .page-ged .ged-recherche input:focus-visible { border: 0; outline: none; box-shadow: none; }
.page-ged .ged-recherche input { flex: 1; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; outline: none; box-shadow: none; background: none; color: var(--encre); font: 500 14px var(--police); }
.ged-segment { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-3); }
.ged-segment button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--encre-2); font: 700 14px var(--police); cursor: pointer; }
.ged-segment button .bp-ico { width: 17px; height: 17px; }
.ged-segment button.actif { background: var(--surface); color: var(--encre); box-shadow: var(--ombre); }

.ged-ariane { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 10px; color: var(--encre-3); }
.ged-ariane > .bp-ico { width: 16px; height: 16px; }
.ged-ariane .courant { font-weight: 800; }
.ged-filtres { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; font-size: 13px; color: var(--encre-3); }
.ged-puce { padding: 4px 10px; border: 1px solid var(--primaire); border-radius: 999px; background: var(--primaire-pale); color: var(--primaire); font: 600 12.5px var(--police); cursor: pointer; }

/* Grille de pièces */
.ged-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.ged-carte { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--trait); border-radius: 18px; background: var(--surface); box-shadow: var(--ombre); cursor: pointer; outline: none; transition: transform .15s, box-shadow .15s; }
.ged-carte:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(10, 20, 70, .12); }
.ged-carte:focus-visible { box-shadow: 0 0 0 3px var(--primaire); }
.ged-carte-corps { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; padding: 22px 22px 14px; }
.ged-carte-tete { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.ged-carte-tete > div { min-width: 0; }
.ged-carte-tete b { display: block; font: 800 16px/1.3 var(--police); color: var(--encre); overflow-wrap: anywhere; }
.ged-personne, .ged-meta, .ged-ligne-dossier { overflow-wrap: anywhere; }
.ged-table td:first-child { overflow-wrap: anywhere; min-width: 220px; }
.ged-table td:nth-child(4), .ged-table td:last-child { white-space: nowrap; }
.ged-table td:last-child .bp-cell-actions { flex-wrap: nowrap; }
.ged-carte-tete small { color: var(--encre-2); font-size: 13px; }
.ged-tuile { flex: 0 0 52px; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--c); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 40%, transparent); }
.ged-tuile .bp-ico { width: 24px; height: 24px; }
.ged-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.ged-badges:empty { display: none; }
.ged-ligne-dossier, .ged-sous { display: flex; align-items: center; gap: 5px; margin: 0; color: var(--encre-3); font-size: 12.5px; }
.ged-ligne-dossier .bp-ico, .ged-sous .bp-ico { width: 13px; height: 13px; }
.ged-personne { margin: 0; color: var(--encre-2); font-size: 14px; }
.ged-meta { margin: 0; color: var(--encre-3); font-size: 12.5px; }
.ged-echeance { margin: 0; color: var(--encre-2); font-size: 13.5px; }
.ged-echeance.echue, .ged-sous.echue { color: var(--rouge); font-weight: 700; }
.ged-carte-pied { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 22px 16px; border-top: 1px solid var(--trait); }
.ged-carte-pied .btn .bp-ico, .ged-table .btn .bp-ico { width: 16px; height: 16px; }
.ged-icone-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--encre-2); cursor: pointer; }
.ged-icone-btn:hover, .ged-icone-btn:focus-visible { background: var(--surface-3); color: var(--encre); }
.ged-icone-btn .bp-ico { width: 20px; height: 20px; }
.ged-table td small.ged-sous { margin-top: 2px; }
.page-ged .bp-empty .btn { margin-top: 12px; }

/* Menu contextuel */
.ged-menu { position: fixed; z-index: 1000; min-width: 260px; padding: 8px; border: 1px solid var(--trait); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 40px rgba(10, 20, 70, .2); }
.ged-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 9px; background: none; color: var(--encre); font: 500 15px var(--police); text-align: left; cursor: pointer; }
.ged-menu button:hover, .ged-menu button:focus-visible { background: var(--surface-2); outline: none; }
.ged-menu button.danger { color: var(--rouge); }
.ged-menu button.inerte { color: var(--encre-2); }
.ged-menu .bp-ico { width: 18px; height: 18px; color: var(--encre-2); }
.ged-menu button.danger .bp-ico { color: var(--rouge); }
.ged-menu hr { margin: 6px 4px; border: 0; border-top: 1px solid var(--trait); }

/* Fiche */
.ged-fenetre-corps { padding: 4px 0 8px; }
.ged-fiche dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 18px 0 0; }
.ged-fiche dt { color: var(--encre-3); font-size: 13px; }
.ged-fiche dd { margin: 0; font-weight: 600; }
.ged-fiche .ged-badges { margin-top: 6px; }
.ged-note { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.ged-fenetre-pied { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.ged-fenetre-pied .bp-ico { width: 16px; height: 16px; }

/* ═══ Journaux & audit ═══ */
.page-journaux .j-onglets { margin: 4px 0 12px; }
.page-journaux .j-onglets button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--encre-2); font: 700 14px var(--police); cursor: pointer; }
.page-journaux .j-onglets button.actif { background: var(--surface); color: var(--encre); box-shadow: var(--ombre); }
.page-journaux .j-onglets .bp-ico { width: 17px; height: 17px; }
.page-journaux .j-filtres { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; padding: 14px; border: 1px solid var(--trait); border-radius: 16px; background: var(--surface); }
.page-journaux .j-filtres label { display: grid; gap: 4px; min-width: 130px; font: 700 12px var(--police); color: var(--encre-2); }
.page-journaux .j-filtres .j-large { flex: 1 1 200px; }
.page-journaux .j-filtres input, .page-journaux .j-filtres select { min-height: 40px; }
.page-journaux .j-boutons { display: flex; gap: 6px; }
.page-journaux .j-pages { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.page-journaux .j-pages .bp-ico, .page-journaux .bp-actions .bp-ico { width: 16px; height: 16px; }
.page-journaux td code { font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 980px) {
  .ged-corps { grid-template-columns: 1fr; }
  .ged-arbre { position: static; max-height: 360px; }
  .ged-fiche dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .ged-carte { transition: none; } .ged-carte:hover { transform: none; } }
