/* ══════════════════════════════════════════════════════════════
   csrd-workspace.css — Espace unique « Rapport de durabilité »
   Utilise uniquement les variables de app.css (--c-*, --bg-*, --txt-*,
   --border, --r-*, --rose, --shadow-*). Préfixe .csw- : aucun conflit.
   ══════════════════════════════════════════════════════════════ */

/* L'ancienne navigation éclatée disparaît : tout est dans une page */
body.csw-on .ni[data-nav="esg-social-gov"],
body.csw-on #csrd-settings-btn { display: none !important; }
#csw-legacy .ai-hero { padding: 0; background: none; border: 0; margin-bottom: .75rem }
#csw-legacy .ai-hero-ico, #csw-legacy .ai-hero h2, #csw-legacy .ai-hero p { display: none }
#csw-legacy .ai-actions-row { margin-top: 0 }
#csw-legacy .ai-card { margin-top: .5rem }

.csw { --csw-gap: 1rem; color: var(--txt); }
.csw *, .csw *::before, .csw *::after { box-sizing: border-box }

/* ── Barre supérieure collante ─────────────────────────────── */
.csw-top {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto auto; gap: .75rem 1.25rem; align-items: center;
  padding: .75rem 1rem; margin-bottom: 1rem;
  background: color-mix(in srgb, var(--bg-1) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm, 0 1px 3px rgba(21,24,26,.06));
}
.csw-title { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; min-width: 0 }
.csw-title h2 { font-size: 1.05rem; font-weight: 700; margin: 0 }
.csw-year { font-size: .78rem; color: var(--txt-3); font-weight: 600 }
.csw-saved { font-size: .74rem; color: var(--txt-3); flex-basis: 100% }
.csw-saved.dirty { color: var(--amber, #B7791F); font-weight: 600 }

.csw-seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px }
.csw-seg button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 150px;
  padding: .4rem .8rem; border: 0; border-radius: 9px; background: transparent; color: var(--txt-2); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s; text-align: left; font: inherit;
}
.csw-seg button b { font-size: .85rem } .csw-seg button small { font-size: .68rem; opacity: .75 }
.csw-seg button:hover { background: var(--bg-3) }
.csw-seg button.on { background: var(--bg-1); color: var(--c-600, var(--c-500)); box-shadow: 0 1px 4px rgba(21,24,26,.12) }
.csw-seg button:focus-visible, .csw-yn button:focus-visible, .csw-rail a:focus-visible { outline: 2px solid var(--c-500); outline-offset: 2px }

.csw-topr { display: flex; align-items: center; gap: .6rem }
.csw-topr .btn-ai.dirty { box-shadow: 0 0 0 3px rgba(183,121,31,.25) }
.csw-ring { --p: 0; position: relative; width: 44px; height: 44px; flex: none; display: grid; place-items: center }
.csw-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--c-500) calc(var(--p) * 1%), var(--bg-5) 0);
  -webkit-mask: radial-gradient(circle at center, transparent 15px, #000 16px); mask: radial-gradient(circle at center, transparent 15px, #000 16px);
}
.csw-ring b { position: relative; font-size: .66rem; color: var(--txt) }
.csw-ring.ok b { color: var(--c-600, var(--c-500)) }

/* ── Corps : rail + contenu ────────────────────────────────── */
.csw-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.25rem; align-items: start }
.csw-rail { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 2px; padding: .35rem; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-md) }
.csw-rail a { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem .7rem; border-radius: 8px; color: var(--txt-2); font-size: .82rem; font-weight: 500; text-decoration: none; transition: background .15s }
.csw-rail a:hover { background: var(--bg-3); color: var(--txt) }
.csw-rail small { font-size: .68rem; font-weight: 700; color: var(--txt-3); background: var(--bg-2); padding: 1px 7px; border-radius: 99px }
.csw-rail small.ok { color: var(--c-600, var(--c-500)); background: var(--bg-4) }

.csw-main { display: flex; flex-direction: column; gap: var(--csw-gap); min-width: 0 }
.csw-sec { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: 1.1rem 1.25rem 1.25rem; scroll-margin-top: 96px }
.csw-sec > h3 { display: flex; align-items: center; gap: .55rem; font-size: .98rem; font-weight: 700; margin: 0 0 .85rem; color: var(--txt) }
.csw-sec > h3 i, .csw-sec > h3 svg { color: var(--c-500); flex: none }

/* ── Groupes repliables ────────────────────────────────────── */
.csw-grp { border: 1px solid var(--border); border-radius: 12px; margin-top: .7rem; background: var(--bg-1) }
.csw-grp > summary, .csw-dmar > summary, .csw-miss > summary, .csw-gaps > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .6rem; padding: .65rem .9rem; font-size: .86rem; font-weight: 600; border-radius: 12px
}
.csw-grp > summary::-webkit-details-marker, .csw-dmar > summary::-webkit-details-marker, .csw-miss > summary::-webkit-details-marker, .csw-gaps > summary::-webkit-details-marker { display: none }
.csw-grp > summary::before, .csw-miss > summary::before, .csw-gaps > summary::before { content: '›'; font-size: 1.1rem; line-height: 1; color: var(--txt-3); transition: transform .15s }
.csw-grp[open] > summary::before, .csw-miss[open] > summary::before, .csw-gaps[open] > summary::before { transform: rotate(90deg) }
.csw-grp > summary:hover { background: var(--bg-3) }
.csw-gt { flex: 1 }
.csw-grp > .csw-grid, .csw-grp > .csw-nmnote { margin: 0 .9rem .9rem }
.csw-nm { opacity: .72 }
.csw-nmnote { font-size: .76rem; color: var(--txt-3); font-style: italic; padding-top: .2rem }
.csw-cnt { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--bg-2); color: var(--txt-3) }
.csw-cnt.ok { background: var(--bg-4); color: var(--c-600, var(--c-500)) }

/* ── Champs ────────────────────────────────────────────────── */
.csw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .85rem 1rem; padding-top: .35rem }
.csw-f { min-width: 0 }
.csw-f.csw-wide { grid-column: 1 / -1 }
.csw-lbl { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .4rem; font-size: .78rem; font-weight: 600; color: var(--txt-2); margin-bottom: .3rem }
.csw-req { color: var(--rose); font-style: normal; font-weight: 700 }
.csw-f .f-input, .csw-f .f-select, .csw-f .f-textarea { width: 100% }
.csw-f .f-input[readonly] { background: var(--bg-2); color: var(--txt-2); cursor: not-allowed }
.csw-num { position: relative; display: flex; align-items: center }
.csw-num .f-input { padding-right: 2.6rem }
.csw-unit { position: absolute; right: .65rem; font-size: .72rem; color: var(--txt-3); pointer-events: none }
.csw-hint { font-size: .74rem; color: var(--txt-3); margin-top: .25rem; line-height: 1.45 }
.csw-warn { font-size: .74rem; color: var(--amber, #B7791F); margin-top: .25rem; font-weight: 500 }
.csw-flash { animation: cswFlash 1.4s ease }
@keyframes cswFlash { 0%, 60% { box-shadow: 0 0 0 4px rgba(24,154,94,.28); border-radius: 10px } 100% { box-shadow: none } }

.csw-chip { display: inline-flex; align-items: center; font-size: .64rem; font-weight: 700; letter-spacing: .02em; padding: 1px 7px; border-radius: 99px; background: var(--bg-2); color: var(--txt-3); border: 1px solid var(--border); white-space: nowrap }
.csw-chip-v { background: rgba(14,116,144,.08); color: #0E7490; border-color: rgba(14,116,144,.25) }
.csw-chip-ok { background: var(--bg-4); color: var(--c-600, var(--c-500)); border-color: var(--c-200) }
.csw-chip-mute { background: var(--bg-2); color: var(--txt-3) }
.csw-src-auto { background: rgba(24,154,94,.1); color: var(--c-600, var(--c-500)); border-color: var(--c-200) }
.csw-src-prev { background: rgba(183,121,31,.1); color: #B7791F; border-color: rgba(183,121,31,.3) }
.csw-src-lock { background: rgba(99,102,241,.09); color: #4F46E5; border-color: rgba(99,102,241,.25) }
.csw-src-saved { background: transparent; color: var(--txt-3) }

/* Oui / Non */
.csw-yn { display: inline-flex; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden }
.csw-yn button { padding: .38rem 1.05rem; border: 0; background: var(--bg-1); color: var(--txt-2); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s }
.csw-yn button + button { border-left: 1.5px solid var(--border) }
.csw-yn button:hover { background: var(--bg-3) }
.csw-yn button.on { background: var(--c-500); color: #fff }
.csw-yn button.on.no { background: var(--txt-2) }
.csw-desc { margin-top: .5rem }

/* Tableaux en ligne (remplacent les modales) */
.csw-rows { display: flex; flex-direction: column; gap: .4rem; overflow-x: auto; padding-bottom: .2rem }
.csw-row { display: flex; gap: .4rem; align-items: center; min-width: max-content }
.csw-row .f-input { flex: 1 1 140px; min-width: 110px; padding: .4rem .55rem; font-size: .8rem }
.csw-rowhead { font-size: .68rem; font-weight: 700; color: var(--txt-3); text-transform: uppercase; letter-spacing: .03em }
.csw-rowhead span { flex: 1 1 140px; min-width: 110px }
.csw-xsp, .csw-x { flex: 0 0 28px }
.csw-x { width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--txt-3); font-size: 1.1rem; cursor: pointer }
.csw-x:hover { background: rgba(220,38,38,.1); color: var(--rose) }
.csw-add { align-self: flex-start; border: 1.5px dashed var(--c-200); background: transparent; color: var(--c-600, var(--c-500)); border-radius: 9px; padding: .35rem .8rem; font: inherit; font-size: .78rem; font-weight: 600; cursor: pointer }
.csw-add:hover { background: var(--bg-3) }

/* ── Profil ────────────────────────────────────────────────── */
.csw-profile { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; margin-bottom: .4rem }
.csw-kv { display: flex; flex-direction: column; padding: .55rem .75rem; background: var(--bg-2); border-radius: 10px; font-size: .72rem; color: var(--txt-3) }
.csw-kv b { font-size: .88rem; color: var(--txt); font-weight: 600; word-break: break-word } .csw-kv em { color: var(--txt-3); font-weight: 400 }
.csw-note { margin: .6rem 0; padding: .65rem .9rem; border-radius: 10px; font-size: .8rem; line-height: 1.5; border: 1px solid }
.csw-note.info { background: rgba(14,116,144,.06); border-color: rgba(14,116,144,.2); color: #155E75 }
.csw-note.warn { background: rgba(183,121,31,.08); border-color: rgba(183,121,31,.3); color: #8A5A14 }

/* ── Données calculées (E1) ────────────────────────────────── */
.csw-calc { padding: .85rem 1rem; background: linear-gradient(135deg, var(--bg-3), rgba(47,125,84,.04)); border: 1px solid var(--c-200); border-radius: 12px }
.csw-calc-h { display: flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 700; margin-bottom: .6rem }
.csw-calc-g { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem }
.csw-calc-g div { display: flex; flex-direction: column; padding: .5rem .7rem; background: var(--bg-1); border-radius: 9px }
.csw-calc-g span { font-size: .68rem; color: var(--txt-3); font-weight: 600 } .csw-calc-g b { font-size: 1.05rem } .csw-calc-g .tot b { color: var(--c-600, var(--c-500)) }

/* ── Double matérialité ────────────────────────────────────── */
.csw-dma { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem }
.csw-dmar { border: 1px solid var(--border); border-radius: 11px }
.csw-dmar > summary { display: grid; grid-template-columns: 34px minmax(0, 1fr) 110px 110px 110px; gap: .6rem; align-items: center; padding: .5rem .8rem }
.csw-dmar > summary:hover { background: var(--bg-3) }
.csw-dmar > summary label { display: flex; flex-direction: column; font-size: .66rem; color: var(--txt-3); font-weight: 600; gap: 2px }
.csw-dmar .f-select { padding: .25rem .4rem; font-size: .8rem }
.csw-dmal { font-weight: 500; font-size: .84rem; min-width: 0 } .csw-dmab { text-align: right }
.csw-dmar > .csw-grid { padding: 0 .8rem .8rem }

/* ── Rapport ───────────────────────────────────────────────── */
.csw-rep-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem 1rem; align-items: center }
.csw-conf { display: flex; flex-direction: column; padding: .55rem .9rem; border-radius: 10px; background: rgba(183,121,31,.08); border: 1px solid rgba(183,121,31,.3); font-size: .8rem }
.csw-conf span { font-size: .72rem; color: var(--txt-2) } .csw-conf.ok { background: var(--bg-4); border-color: var(--c-200) }
.csw-rep-act { display: flex; gap: .5rem; flex-wrap: wrap }
.csw-bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem 1.2rem; margin: 1rem 0 .6rem }
.csw-bar { display: grid; grid-template-columns: 90px 1fr 40px; gap: .5rem; align-items: center; font-size: .76rem; color: var(--txt-2) } .csw-bar em { color: var(--txt-3); font-style: normal; font-size: .66rem }
.csw-bar i { display: block; height: 6px; background: var(--bg-5); border-radius: 99px; overflow: hidden } .csw-bar u { display: block; height: 100%; background: var(--c-500); border-radius: 99px; text-decoration: none }
.csw-bar b { text-align: right; font-size: .7rem }
.csw-miss, .csw-gaps { border: 1px solid var(--border); border-radius: 11px; margin-top: .6rem }
.csw-miss ul, .csw-gaps ul { margin: 0 .9rem .8rem 2rem; font-size: .8rem; line-height: 1.7; columns: 2; column-gap: 2rem } .csw-gaps ul { columns: 1 }
.csw-miss a { color: var(--c-600, var(--c-500)); text-decoration: none; font-weight: 500 } .csw-miss a:hover { text-decoration: underline } .csw-miss small { color: var(--txt-3) }
.csw-gaps .csw-hint { margin: 0 .9rem .4rem }
.csw-sign { margin-top: .9rem } #csw-legacy, #csw-vsme-out { margin-top: 1rem }
.csw-vhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem }
.csw-vs { padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 11px; margin-bottom: .55rem; font-size: .84rem; line-height: 1.6 }
.csw-vs h4 { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; margin: 0 0 .35rem; font-size: .88rem }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 980px) {
  .csw-top { grid-template-columns: 1fr auto; position: static }
  .csw-seg { grid-column: 1 / -1; width: 100% } .csw-seg button { flex: 1; min-width: 0 }
  .csw-body { grid-template-columns: 1fr }
  .csw-rail { position: sticky; top: 0; z-index: 15; flex-direction: row; overflow-x: auto; padding: .3rem; scrollbar-width: none }
  .csw-rail::-webkit-scrollbar { display: none } .csw-rail a { white-space: nowrap; flex: none }
  .csw-sec { scroll-margin-top: 64px }
}
@media (max-width: 640px) {
  .csw-sec { padding: .9rem .85rem 1rem } .csw-grid { grid-template-columns: 1fr }
  .csw-calc-g { grid-template-columns: repeat(2, 1fr) } .csw-miss ul { columns: 1 }
  .csw-dmar > summary { grid-template-columns: 30px 1fr 1fr; } .csw-dmal { grid-column: 2 / -1; grid-row: 1 } .csw-dmab { grid-column: 1 / -1; text-align: left }
  .csw-topr { width: 100%; justify-content: space-between } .csw-topr .btn-ai { flex: 1 }
  .csw-f .f-input, .csw-f .f-select, .csw-f .f-textarea { font-size: max(.8rem, 16px) }
}
@media (prefers-reduced-motion: reduce) { .csw *, .csw-flash { animation: none !important; transition: none !important } }

/* Brouillon IA + aperçu VSME */
.csw-ai { margin-top: .4rem; padding: .28rem .65rem; border: 1px solid var(--c-200); border-radius: 8px; background: var(--bg-3); color: var(--c-600, var(--c-500)); font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer }
.csw-ai:hover:not(:disabled) { background: var(--bg-4) } .csw-ai:disabled { opacity: .6; cursor: wait }
.csw-vdata { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .45rem; margin: .4rem 0 }
.csw-vdata .csw-kv { text-transform: none } .csw-vdata .csw-kv span { text-transform: capitalize }
.csw-vreq { margin: .3rem 0 0 1.1rem; padding: 0; font-size: .74rem; color: var(--txt-3); line-height: 1.55 }

.csw-vc { margin-top: .4rem } .csw-vct { font-size: .78rem; font-weight: 600; color: var(--txt-2) }

/* MDR, S2, historique */
.csw-mdr { grid-column: 1 / -1; display: grid; gap: .85rem }
.csw-s2r { display: flex; justify-content: space-between; align-items: center; padding: .25rem 0 }
.csw-s2new { margin-top: .4rem } .csw-s2new > summary { display: inline-block; list-style: none } .csw-s2new > summary::-webkit-details-marker { display: none }
.csw-s2new .btn-cl { margin-top: .6rem }
.csw-audit { width: 100%; border-collapse: collapse; font-size: .78rem }
.csw-audit th { text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--txt-3); padding: .3rem .5rem .3rem 0 }
.csw-audit td { padding: .35rem .5rem .35rem 0; vertical-align: top; border-top: 1px solid var(--border) } .csw-audit td.old { color: var(--txt-3); text-decoration: line-through } .csw-audit small { color: var(--txt-3); text-transform: uppercase; font-size: .66rem }

/* Squelette de chargement */
.csw-skel { display: grid; gap: .8rem; padding: 1.2rem } .csw-skel p { margin: 0; font-size: .8rem; color: var(--txt-3) }
.csw-skel i { display: block; height: 92px; border-radius: 14px; background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: cswSk 1.3s linear infinite }
@keyframes cswSk { to { background-position: -200% 0 } }
.csw-title .csw-year { font-size: .95rem; color: var(--txt) }
.csw-body:has(.csw-skel) .csw-rail:empty { display: none }