/* ═══════════════════════════════════════════════════════════════════════════
   AO Pilot — Design system v2 (refonte premium 06/2026)
   Thème clair par défaut, sombre via [data-theme="dark"].
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Palette claire (défaut) ── */
  --bg        : #f7f7f5;   /* fond de page */
  --surface   : #ffffff;   /* cartes, panneaux */
  --surface2  : #f1f1ef;   /* fonds secondaires (inputs, hover) */
  --surface3  : #e9e9e6;   /* fonds tertiaires */
  --border    : #e4e4e0;
  --border2   : #d4d4cf;
  --text      : #1a1a18;
  --text2     : #57534e;
  --text3     : #8b8881;
  --accent    : #4f46e5;   /* indigo profond — actions principales */
  --accent2   : #6366f1;
  --accent-bg : #eef2ff;
  --green     : #16a34a;
  --green-bg  : #f0fdf4;
  --amber     : #d97706;
  --amber-bg  : #fffbeb;
  --red       : #dc2626;
  --red-bg    : #fef2f2;
  --blue      : #0284c7;
  --blue-bg   : #f0f9ff;
  --shadow-sm : 0 1px 2px rgba(20, 20, 18, .05);
  --shadow-md : 0 4px 16px rgba(20, 20, 18, .08);
  --shadow-lg : 0 16px 48px rgba(20, 20, 18, .16);
  --r-sm: 8px; --r-md: 10px; --r-lg: 14px;
  /* alias rétrocompatibles (anciens noms utilisés ponctuellement) */
  --red2: var(--red); --green2: var(--green); --amber2: var(--amber);
  --indigo: var(--accent); --indigo2: var(--accent2); --muted: var(--text3);
  --fg: var(--text); --primary: var(--accent); --danger: var(--red);
  --bg-card: var(--surface);
}

[data-theme="dark"] {
  --bg        : #0f1115;
  --surface   : #171a21;
  --surface2  : #1f2330;
  --surface3  : #262b3a;
  --border    : #2a2f3e;
  --border2   : #3a4055;
  --text      : #e7e9ee;
  --text2     : #9aa1b2;
  --text3     : #6b7282;
  --accent    : #818cf8;
  --accent2   : #a5b4fc;
  --accent-bg : rgba(99, 102, 241, .14);
  --green     : #4ade80;
  --green-bg  : rgba(34, 197, 94, .12);
  --amber     : #fbbf24;
  --amber-bg  : rgba(245, 158, 11, .12);
  --red       : #f87171;
  --red-bg    : rgba(239, 68, 68, .12);
  --blue      : #38bdf8;
  --blue-bg   : rgba(14, 165, 233, .12);
  --shadow-sm : 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md : 0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg : 0 16px 48px rgba(0, 0, 0, .6);
}

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
svg { width: 16px; height: 16px; stroke-width: 1.8; flex-shrink: 0; }
a { color: var(--accent); }

/* ═══ Layout ═══ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: -.5px;
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -.2px; }
.brand-name span { color: var(--accent); }
.brand-tenant { font-size: 11px; color: var(--text3); margin-top: 1px; }
#sidebar-logo { max-height: 26px; max-width: 110px; object-fit: contain; display: none; margin: 0 10px 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: var(--text2);
  cursor: pointer; border: none; background: none; width: 100%;
  text-align: left; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav-item .nav-count {
  margin-left: auto; font-size: 10.5px; font-weight: 700;
  background: var(--red-bg); color: var(--red);
  padding: 1px 7px; border-radius: 99px;
}

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.quota-mini { padding: 0 10px 12px; }
.quota-mini-label { font-size: 11px; color: var(--text3); margin-bottom: 5px; display: flex; justify-content: space-between; }
.quota-mini-bar { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; }
.quota-mini-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .4s; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 4px 10px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-email { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 10.5px; color: var(--text3); text-transform: capitalize; }
.icon-btn {
  background: none; border: none; cursor: pointer; color: var(--text3);
  padding: 6px; border-radius: 7px; display: inline-flex; transition: all .12s;
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Zone principale ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 22px;
}
.topbar-title { font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 99px;
  border: none; cursor: pointer; transition: opacity .12s;
}
.pill:hover { opacity: .8; }
.pill-idle    { background: var(--surface2); color: var(--text3); }
.pill-active  { background: var(--green-bg); color: var(--green); }
.pill-working { background: var(--amber-bg); color: var(--amber); }
.pill-dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; }
.pill-dot.pulse { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }
@keyframes spin { to { transform: rotate(360deg); } }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-quota { font-size: 12px; color: var(--text3); white-space: nowrap; }

.content { flex: 1; overflow-y: auto; padding: 24px 26px 48px; }
.content.full-bleed { padding: 18px 22px 24px; }

/* ═══ Composants ═══ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 550; font-family: inherit;
  cursor: pointer; border: 1px solid transparent; transition: all .13s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--text2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: transparent; }
.btn-danger:hover:not(:disabled) { filter: brightness(.96); }
.btn-success { background: var(--green-bg); color: var(--green); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 3px 9px; font-size: 11px; border-radius: 6px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }

.section-title { font-size: 14px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title small { font-weight: 400; color: var(--text3); font-size: 12px; }
.section-gap { margin-bottom: 22px; }

input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border2); background: var(--surface);
  color: var(--text); font-size: 13px; font-family: inherit; outline: none;
  transition: border .13s, box-shadow .13s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
label { display: block; font-size: 12px; font-weight: 550; color: var(--text2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.field small, .hint { font-size: 11px; color: var(--text3); display: block; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }

/* ── Badges / tags ── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  white-space: nowrap;
}
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-amber { background: var(--amber-bg); color: var(--amber); }
.tag-red   { background: var(--red-bg);   color: var(--red); }
.tag-blue  { background: var(--blue-bg);  color: var(--blue); }
.tag-accent{ background: var(--accent-bg);color: var(--accent); }
.tag-gray  { background: var(--surface2); color: var(--text3); }

/* ── KPI / stats ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 15px 17px; box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11.5px; color: var(--text3); font-weight: 500; margin-bottom: 5px; }
.kpi-value { font-size: 25px; font-weight: 700; letter-spacing: -.5px; }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* ── Liste "À traiter" ── */
.todo-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface);
  margin-bottom: 7px; transition: border .13s, box-shadow .13s; cursor: pointer;
}
.todo-row:hover { border-color: var(--accent2); box-shadow: var(--shadow-sm); }
.todo-title { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-meta { font-size: 12px; color: var(--text3); white-space: nowrap; }

/* ── Onglets internes ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 9px 15px; font-size: 13px; font-weight: 550; color: var(--text3);
  cursor: pointer; background: none; border: none; font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 7px; transition: color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .tab-count { font-size: 10px; font-weight: 700; background: var(--surface2); color: var(--text3); padding: 1px 6px; border-radius: 99px; }

/* ── Kanban ── */
.kanban-board {
  display: flex; gap: 12px; align-items: flex-start;
  overflow-x: auto; padding-bottom: 12px; min-height: 60vh;
}
.kanban-col {
  width: 248px; flex-shrink: 0;
  background: var(--surface2); border-radius: var(--r-md);
  border-top: 3px solid var(--border2); padding: 10px;
}
.kanban-col.col-en-cours { border-top-color: var(--accent2); }
.kanban-col.col-etudier  { border-top-color: var(--amber); }
.kanban-col.col-go       { border-top-color: var(--green); }
.kanban-col.col-reponse  { border-top-color: var(--blue); }
.kanban-col.col-gagne    { border-top-color: #ca8a04; }
.kanban-col.col-perdu    { border-top-color: var(--text3); }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.kanban-col-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); }
.kanban-col-count { font-size: 11px; font-weight: 700; background: var(--surface); color: var(--text3); padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 11px 12px; margin-bottom: 8px;
  cursor: pointer; transition: border .12s, box-shadow .12s, transform .12s;
  box-shadow: var(--shadow-sm);
}
.kanban-card:hover { border-color: var(--accent2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card-name { font-size: 13px; font-weight: 600; line-height: 1.35; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kanban-card-meta { font-size: 11.5px; color: var(--text3); line-height: 1.6; }
.kanban-card-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.kanban-status-btns { display: none; gap: 4px; flex-wrap: wrap; margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--border); }
.kanban-card:hover .kanban-status-btns { display: flex; }
.kanban-status-btn {
  font-size: 10.5px; padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--border2); background: var(--surface);
  color: var(--text2); cursor: pointer; font-family: inherit;
}
.kanban-status-btn:hover { background: var(--surface2); color: var(--text); }
.kanban-empty { font-size: 12px; color: var(--text3); text-align: center; padding: 18px 6px; }

/* ── Détail dossier ── */
.detail-back {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: none; color: var(--text2); cursor: pointer;
  font-size: 13px; font-weight: 550; font-family: inherit; padding: 6px 0; margin-bottom: 12px;
}
.detail-back:hover { color: var(--accent); }
.detail-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.detail-title { font-size: 19px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 6px; }
.detail-badges { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }

/* — Parcours guidé en 4 étapes — */
.stepper {
  display: flex; align-items: stretch; gap: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 8px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm); overflow-x: auto;
}
.stepper .step {
  flex: 1 1 0; min-width: 120px; position: relative;
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--text3); text-align: left; transition: background .15s, color .15s;
}
.stepper .step:hover { background: var(--surface2, rgba(127,127,127,.06)); }
.stepper .step.active { background: var(--accent-soft, rgba(99,102,241,.1)); color: var(--text1); }
.stepper .step.done .step-num { background: var(--green, #16a34a); border-color: transparent; color: #fff; }
.step-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--bg, #fff); border: 1.5px solid var(--border); color: var(--text3);
}
.stepper .step.active .step-num { background: var(--accent); border-color: transparent; color: #fff; }
.step-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.step-txt b { font-size: 13px; font-weight: 650; }
.step-txt small { font-size: 11px; color: var(--text3); }
.step-badge {
  position: absolute; top: 6px; right: 8px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--amber, #d97706); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.step-sep { display: none; }
.step-pane[hidden] { display: none; }
.step-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 4px; padding-top: 4px;
}
@media (max-width: 720px) {
  .step-txt small { display: none; }
  .stepper .step { min-width: 84px; justify-content: center; }
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.panel-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.e5-banner {
  display: flex; align-items: center; gap: 18px;
  border-radius: var(--r-md); padding: 14px 18px; margin-bottom: 14px;
}
.e5-banner.go, .e5-banner.go-fort { background: var(--green-bg); }
.e5-banner.etudier { background: var(--amber-bg); }
.e5-banner.nogo { background: var(--red-bg); }
.e5-score { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.go .e5-score, .go-fort .e5-score { color: var(--green); }
.etudier .e5-score { color: var(--amber); }
.nogo .e5-score { color: var(--red); }
.e5-label { font-size: 14px; font-weight: 650; }
.e5-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.crit-row { display: grid; grid-template-columns: 175px 1fr 42px; gap: 10px; align-items: center; padding: 5px 0; }
.crit-name { font-size: 12.5px; color: var(--text2); }
.crit-bar-wrap { height: 7px; background: var(--surface3); border-radius: 4px; overflow: hidden; }
.crit-bar { height: 100%; border-radius: 4px; transition: width .4s; }
.crit-pct { font-size: 12px; font-weight: 650; text-align: right; }
.crit-expl { grid-column: 1 / -1; font-size: 11.5px; color: var(--text3); padding: 0 0 4px; }

.dl-grid { display: flex; gap: 7px; flex-wrap: wrap; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-sm); font-size: 12px; font-weight: 550;
  border: 1px solid var(--border2); background: var(--surface); color: var(--text2);
  cursor: pointer; font-family: inherit; transition: all .12s;
}
.dl-btn:hover { border-color: var(--accent2); color: var(--accent); background: var(--accent-bg); }
.dl-btn.dl-main { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); font-weight: 650; }
.dl-btn.dl-del { color: var(--red); }
.dl-btn.dl-del:hover { border-color: var(--red); background: var(--red-bg); }

/* Checklist E6 */
.ck-item {
  display: flex; align-items: flex-start; gap: 12px; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-bottom: 7px;
}
.ck-item.obtenu  { background: var(--green-bg); border-color: transparent; }
.ck-item.manquant{ background: var(--red-bg);   border-color: transparent; }
.ck-label { font-size: 13px; font-weight: 550; }
.ck-desc, .ck-validity { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.ck-rag { font-size: 11.5px; color: var(--green); margin-top: 3px; }
.ck-rag.expired { color: var(--amber); }
.ck-btns { display: flex; gap: 5px; flex-shrink: 0; }
.ck-btn {
  font-size: 11px; padding: 4px 9px; border-radius: 6px; cursor: pointer; font-family: inherit;
  border: 1px solid var(--border2); background: var(--surface); color: var(--text3);
}
.ck-btn.active-obtenu  { background: var(--green); color: #fff; border-color: var(--green); }
.ck-btn.active-manquant{ background: var(--red);   color: #fff; border-color: var(--red); }
.ck-btn.active-af      { background: var(--text3); color: #fff; border-color: var(--text3); }
.ck-progress { height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; margin: 8px 0 14px; }
.ck-progress-bar { height: 100%; background: var(--green); border-radius: 3px; transition: width .4s; }

/* Co-pilote validation */
.vp-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.vp-wrap.vp-ok { color: var(--green); font-size: 13px; font-weight: 550; background: var(--green-bg); border-color: transparent; }
.vp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; margin-bottom: 12px; flex-wrap: wrap; }
.vp-head.vp-pret span { color: var(--green); font-weight: 600; }
.vp-row { display: flex; gap: 11px; padding: 9px 0; border-top: 1px solid var(--border); }
.vp-row.vp-done { opacity: .5; }
.vp-title { font-size: 13px; font-weight: 550; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.vp-msg { font-size: 12px; color: var(--text2); margin-top: 3px; }
.vp-action { font-size: 12px; color: var(--accent); margin-top: 3px; }
.vp-tag { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.vp-haute   { background: var(--red-bg);   color: var(--red); }
.vp-moyenne { background: var(--amber-bg); color: var(--amber); }
.vp-info    { background: var(--blue-bg);  color: var(--blue); }
.vp-src { font-size: 10px; color: var(--text3); }
.vp-check input { width: 16px; height: 16px; cursor: pointer; }

/* Compléments / pièces (details) */
.cf-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 18px; margin-bottom: 16px; }
.cf-wrap summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.cf-wrap summary small { font-weight: 400; color: var(--text3); }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 14px; }
.cf-field span { display: block; font-size: 12px; font-weight: 550; color: var(--text2); margin-bottom: 4px; }
.cf-field.cf-full { display: block; margin-top: 12px; }
.cf-hint { color: var(--text3); font-size: 11px; }
.cf-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.cf-status { font-size: 12px; color: var(--text3); }
.dp-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.dp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-meta { font-size: 11px; color: var(--text3); white-space: nowrap; }
.dp-empty { font-size: 12px; color: var(--text3); padding: 8px 0; }
.dp-upload { border-top: 1px solid var(--border); padding-top: 12px; }
.dp-input { width: auto; flex: 1; min-width: 140px; }

/* Éditeur de mémoire par sections */
/* — Éditeur mémoire : sommaire sticky + sections délimitées — */
.mem-layout { display: flex; align-items: flex-start; gap: 22px; }
.mem-main { flex: 1; min-width: 0; }

.mem-toc {
  position: sticky; top: 78px; flex: none; width: 232px;
  max-height: calc(100vh - 100px); overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); padding: 12px 10px; box-shadow: var(--shadow-sm);
}
.mem-toc-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); padding: 0 6px 9px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.mem-toc-list { list-style: none; margin: 0; padding: 0; }
.mem-toc-list a {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 8px; border-radius: var(--r-sm, 7px);
  font-size: 12.5px; line-height: 1.35; color: var(--text2);
  text-decoration: none; border-left: 2px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.mem-toc-list a:hover { background: var(--surface2, rgba(127,127,127,.06)); color: var(--text1); }
.mem-toc-list a.active {
  background: var(--accent-soft, rgba(99,102,241,.1));
  color: var(--text1); font-weight: 600; border-left-color: var(--accent);
}
.toc-num {
  flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
  background: var(--bg, #fff); border: 1px solid var(--border); color: var(--text3);
}
.mem-toc-list a.active .toc-num { background: var(--accent); border-color: transparent; color: #fff; }
.toc-lbl { display: block; min-width: 0; }

#mem-sections, #ana-sections { display: flex; flex-direction: column; gap: 18px; }
.mem-sec {
  scroll-margin-top: 82px;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r-md); background: var(--surface);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: border-color .13s, box-shadow .13s;
}
@media (max-width: 920px) {
  .mem-toc { display: none; }   /* sur petit écran, lecture pleine largeur */
}
.mem-sec:hover { border-color: var(--border2); box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,.07)); }
.mem-sec-head {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 11px 16px; background: var(--surface2, rgba(127,127,127,.05));
  border-bottom: 1px solid var(--border);
}
.mem-sec-title { font-size: 15px; font-weight: 700; letter-spacing: -.2px; color: var(--text1); }
.mem-sec-body {
  font-size: 14px; line-height: 1.7; color: var(--text2);
  padding: 16px 18px 18px;
}
/* Aération du markdown à l'intérieur d'une section */
.mem-sec-body > :first-child { margin-top: 0; }
.mem-sec-body > :last-child { margin-bottom: 0; }
.mem-sec-body p { margin: 0 0 11px; }
.mem-sec-body h3, .mem-sec-body h4 {
  font-size: 13.5px; font-weight: 700; color: var(--text1);
  margin: 18px 0 8px; padding-top: 4px;
}
.mem-sec-body ul, .mem-sec-body ol { margin: 0 0 12px; padding-left: 20px; }
.mem-sec-body li { margin-bottom: 5px; }
.mem-sec-body table { margin: 6px 0 14px; font-size: 13px; }
.mem-sec-tools { padding: 0 16px 14px; }
.mem-sec-tools textarea { margin-top: 8px; }
/* Champ pré-rempli par l'IA (à valider) */
.cf-ia { border-color: var(--amber, #d97706) !important; background: rgba(217,119,6,.04); }

/* Encart « Ce qu'il vous reste à faire » */
.todo-panel { border-left: 3px solid var(--amber, #d97706); }
.todo-panel.ok { border-left-color: var(--green, #16a34a); }
.todo-head { font-size: 13px; font-weight: 700; color: var(--text1); display: flex; align-items: center; gap: 8px; }
.todo-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.todo-list li { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--surface2, rgba(127,127,127,.05)); border-radius: var(--r-md); }
.todo-ico { flex: none; font-size: 15px; }
.todo-txt { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; color: var(--text2); }
.todo-list li button { flex: none; }

/* Panneau « Joindre un document » sous une section */
.attach-box {
  margin-top: 10px; padding: 12px 14px;
  background: var(--surface2, rgba(127,127,127,.05));
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.attach-box input { width: 100%; }
.attach-box .md-body img { max-width: 100%; border-radius: 6px; }

/* Markdown E2 */
.md-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 24px 28px; font-size: 14px; line-height: 1.7; box-shadow: var(--shadow-sm); }
.md-body h1, .md-body h2, .md-body h3 { margin: 1.2em 0 .5em; letter-spacing: -.2px; }
.md-body h1 { font-size: 19px; } .md-body h2 { font-size: 16px; } .md-body h3 { font-size: 14px; }
.md-body table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 13px; }
.md-body td, .md-body th { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-body th { background: var(--surface2); }
.md-body code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.md-body ul, .md-body ol { padding-left: 22px; margin: .5em 0; }
.md-body p { margin: .55em 0; }

/* ── Veille (cards plateformes + AO) ── */
.platform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 20px; }
.platform-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 15px; cursor: pointer; transition: all .13s; box-shadow: var(--shadow-sm);
}
.platform-card:hover { border-color: var(--accent2); }
.platform-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.platform-card.loading { opacity: .55; pointer-events: none; }
.platform-card-icon { font-size: 21px; margin-bottom: 7px; }
.platform-card-name { font-size: 13px; font-weight: 650; margin-bottom: 3px; }
.platform-card-desc { font-size: 11.5px; color: var(--text3); line-height: 1.45; margin-bottom: 8px; }
.platform-card-status { font-size: 11px; font-weight: 600; }
.platform-card-status.connected { color: var(--green); }
.platform-card-status.needs-key { color: var(--amber); }
.platform-card-status.free { color: var(--blue); }

.ao-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 15px 17px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
}
.ao-card-header { display: flex; gap: 14px; align-items: flex-start; }
.ao-score-badge {
  width: 42px; height: 42px; border-radius: var(--r-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
}
.ao-score-badge.high { background: var(--green-bg); color: var(--green); }
.ao-score-badge.mid  { background: var(--amber-bg); color: var(--amber); }
.ao-score-badge.low  { background: var(--surface2); color: var(--text3); }
.ao-title { font-size: 14px; font-weight: 600; line-height: 1.4; margin-bottom: 5px; }
.ao-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text3); }
.ao-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.ao-meta-item svg { width: 13px; height: 13px; }
.ao-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.ao-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--border); align-items: center; }
.veille-empty { text-align: center; padding: 40px 20px; color: var(--text3); font-size: 13px; }
.veille-empty svg { width: 30px; height: 30px; margin-bottom: 8px; }
.veille-toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.veille-toolbar input, .veille-toolbar select { width: auto; }

/* ── Upload (modal Nouvel AO) ── */
.upload-zone {
  border: 2px dashed var(--border2); border-radius: var(--r-lg);
  padding: 34px 20px; text-align: center; cursor: pointer; transition: all .15s;
  background: var(--surface2);
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: var(--accent-bg); }
.upload-zone svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 8px; }
.upload-zone p { font-size: 13.5px; font-weight: 550; }
.upload-zone small { font-size: 12px; color: var(--text3); }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); margin-top: 7px; font-size: 13px; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--text3); white-space: nowrap; }
.file-type-select { width: auto; padding: 4px 8px; font-size: 11.5px; border-radius: 6px; }
.file-type-select.manual { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.file-remove { background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; border-radius: 5px; display: inline-flex; }
.file-remove:hover { color: var(--red); background: var(--red-bg); }

/* ── Mon espace (KB) ── */
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 11px; margin-bottom: 20px; }
.kb-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 15px; cursor: pointer; transition: all .13s; box-shadow: var(--shadow-sm);
}
.kb-tile:hover { border-color: var(--accent2); }
.kb-tile.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.kb-tile-icon { font-size: 19px; margin-bottom: 6px; }
.kb-tile-count { font-size: 21px; font-weight: 750; letter-spacing: -.5px; }
.kb-tile-label { font-size: 11.5px; color: var(--text3); margin-top: 1px; }
.doc-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.doc-name { font-size: 13px; font-weight: 550; }
.doc-meta { font-size: 11.5px; color: var(--text3); margin-top: 1px; }
.doc-info { flex: 1; min-width: 0; }
.completeness { display: flex; align-items: center; gap: 16px; }
.completeness-bar { flex: 1; height: 6px; background: var(--surface3); border-radius: 3px; overflow: hidden; }
.completeness-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width .5s; }

/* ── CRM ── */
.crm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); gap: 13px; }
.crm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 17px; box-shadow: var(--shadow-sm); }
.crm-card-name { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-card-stats { display: flex; gap: 7px; flex-wrap: wrap; margin: 10px 0 4px; }
.crm-card-stat { font-size: 11.5px; background: var(--surface2); color: var(--text2); padding: 3px 9px; border-radius: 99px; }
.crm-card-notes { font-size: 12px; color: var(--text2); background: var(--surface2); border-radius: var(--r-sm); padding: 8px 10px; margin-top: 8px; }
.crm-card-actions { margin-top: 10px; }

/* ── Modals ── */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 15, 20, .45); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  padding: 22px 24px; box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 720px; }
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; display: inline-flex; border-radius: 6px; }
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.warn-box { background: var(--amber-bg); color: var(--amber); border-radius: var(--r-sm); padding: 11px 14px; font-size: 12.5px; line-height: 1.55; margin-bottom: 14px; }
.danger-box { background: var(--red-bg); color: var(--red); border-radius: var(--r-sm); padding: 11px 14px; font-size: 12.5px; line-height: 1.55; margin-bottom: 14px; }
.info-box { background: var(--blue-bg); color: var(--blue); border-radius: var(--r-sm); padding: 11px 14px; font-size: 12.5px; line-height: 1.55; margin-bottom: 14px; }

/* Doc viewer (plein écran) */
.viewer-modal { display: none; position: fixed; inset: 0; z-index: 950; background: rgba(10,10,14,.75); padding: 28px; }
.viewer-modal.open { display: flex; flex-direction: column; }
.viewer-head { display: flex; align-items: center; gap: 12px; color: #fff; padding-bottom: 12px; }
.viewer-title { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { flex: 1; background: var(--surface); border-radius: var(--r-lg); overflow: hidden; position: relative; }
.viewer-body iframe { width: 100%; height: 100%; border: none; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; margin: auto; }
.viewer-fallback { padding: 40px; text-align: center; color: var(--text3); font-size: 13px; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 26px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(14px);
  background: var(--text); color: var(--bg);
  border-radius: 10px; padding: 11px 20px; font-size: 13px; font-weight: 550;
  opacity: 0; transition: all .25s; pointer-events: none;
  max-width: 80vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--shadow-lg);
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.err { background: var(--red); color: #fff; }

/* ── Bannière analyses en cours ── */
.progress-banner {
  display: none; align-items: center; gap: 11px;
  background: var(--accent-bg); border: 1px solid var(--accent2);
  color: var(--accent); border-radius: var(--r-md);
  padding: 10px 15px; font-size: 13px; font-weight: 550; margin-bottom: 16px;
}
.progress-banner.active { display: flex; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent-bg); border-top-color: var(--accent);
  animation: spin .8s linear infinite; flex-shrink: 0;
}

/* ── Vues ── */
.view { display: none; }
.view.active { display: block; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-state svg { width: 30px; height: 30px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; font-weight: 550; color: var(--text2); }
.empty-state small { font-size: 12.5px; }

.text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-green { color: var(--green); }

/* ── Responsive ── */
@media (max-width: 860px) {
  .sidebar { width: 64px; padding: 14px 8px; }
  .brand-name, .brand-tenant, .nav-item span.nav-label, .nav-item .nav-count,
  .user-info, .quota-mini { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .content { padding: 16px 14px 40px; }
}
