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

:root {
  --primary:      #4f46e5;
  --primary-dk:   #3730a3;
  --primary-lt:   #eef2ff;
  --primary-mid:  #c7d2fe;
  --sidebar-w:    220px;
  --topbar-h:     46px;
  --bg:           #f0f0f1;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --border-lt:    #f1f5f9;
  --text:         #0f172a;
  --text-2:       #475569;
  --text-3:       #94a3b8;
  --danger:       #ef4444;
  --danger-dk:    #dc2626;
  --success:      #10b981;
  --r:            10px;
  --r-sm:         7px;
  --sh:           0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --sh-md:        0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --sh-lg:        0 20px 40px rgba(0,0,0,.12);
  --sidebar-bg:        #faf7f2;
  --sidebar-bd:        rgba(0,0,0,.07);
  --sidebar-text:      #111827;
  --sidebar-fs:        .82rem;
  --highlight-color:   #2271b1;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.5; font-size: 14px; -webkit-font-smoothing: antialiased;
}

.page { display: none !important; }
.page.active { display: flex !important; }

/* ═══════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════ */
#page-login {
  min-height: 100vh; align-items: center; justify-content: center;
  background: #f5f6fa; position: relative; overflow: auto; padding: 1.5rem;
}
#page-login::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(55% 45% at 12% 8%,  rgba(99,102,241,.08) 0%, transparent 60%),
    radial-gradient(50% 45% at 92% 95%, rgba(129,140,248,.08) 0%, transparent 60%);
}
.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  background: #ffffff; border: 1px solid #ecedf2;
  border-radius: 22px; padding: 2.75rem 2.5rem 2.25rem;
  box-shadow: 0 1px 2px rgba(16,24,40,.03), 0 18px 48px -16px rgba(16,24,40,.14);
}
.login-brand {
  display: flex; flex-direction: column; align-items: center;
  gap: .85rem; margin-bottom: 2.1rem; text-align: center;
}
.login-brand-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  border: 1px solid #e3e8ff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.55rem;
}
.login-brand-text h1 { font-size: 1.35rem; font-weight: 650; color: #111827; letter-spacing: -.01em; }
.login-brand-text p  { font-size: .82rem; color: #9aa1ae; margin-top: 3px; }

.login-card .field { margin-bottom: 1.05rem; }
.login-card .field label {
  display: block; color: #4b5563; font-size: .8rem; font-weight: 500; margin-bottom: .4rem;
}
.login-card .field input {
  width: 100%;
  background: #f8f9fc; border: 1px solid #e5e8ef; color: #111827;
  border-radius: 12px; padding: .78rem .9rem; font-size: .9rem;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-card .field input::placeholder { color: #b7bdc9; }
.login-card .field input:focus {
  border-color: #a5b4fc; background: #fff;
  outline: none; box-shadow: 0 0 0 4px rgba(129,140,248,.16);
}
.login-remember {
  display: flex; align-items: center; gap: .5rem;
  font-size: .83rem; color: #6b7280; margin: .1rem 0 1.25rem; cursor: pointer;
}
.login-remember input { width: auto; margin: 0; accent-color: #6366f1; }
.btn-login {
  width: 100%; padding: .82rem; border: none; border-radius: 12px;
  background: #4f46e5; color: #fff;
  font-size: .92rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(79,70,229,.5);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn-login:hover  { background: #4338ca; box-shadow: 0 6px 18px -4px rgba(79,70,229,.55); }
.btn-login:active { transform: translateY(1px); }
.login-foot {
  text-align: center; font-size: .74rem; color: #b0b6c0;
  margin-top: 1.5rem; letter-spacing: .01em;
}

/* ═══════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════ */
#page-app { height: 100vh; flex-direction: row; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
  box-shadow: 1px 0 0 var(--sidebar-bd), 2px 0 8px rgba(0,0,0,.04);
  transition: transform .2s ease;
}

.sidebar-header {
  padding: 1.1rem 1rem .9rem;
  border-bottom: 1px solid var(--sidebar-bd);
}
.sidebar-logo { display: flex; align-items: center; gap: .65rem; }
.sidebar-logo-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; box-shadow: 0 2px 8px rgba(79,70,229,.5);
}
.sidebar-logo span  { font-size: .9rem; font-weight: 700; color: var(--sidebar-text); letter-spacing: -.01em; }
.sidebar-logo small { font-size: .62rem; color: color-mix(in srgb, var(--sidebar-text) 45%, var(--sidebar-bg)); display: block; }

.sidebar-user {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--sidebar-bd);
  display: flex; align-items: center; gap: .6rem;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
}
.user-name { font-size: .8rem; font-weight: 600; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .65rem; color: color-mix(in srgb, var(--sidebar-text) 45%, var(--sidebar-bg)); }

.sidebar-nav { flex: 1; padding: .5rem .6rem; }
.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem; border-radius: 6px;
  border: none; background: none; width: 100%; text-align: left;
  color: color-mix(in srgb, var(--sidebar-text) 75%, var(--sidebar-bg)); font-size: var(--sidebar-fs); font-weight: 600;
  cursor: pointer; transition: all .15s; position: relative;
}
.nav-item:hover  { background: color-mix(in srgb, var(--sidebar-text) 9%, var(--sidebar-bg)); color: var(--sidebar-text); }

/* ── Surbrillance — style rempli (défaut, WordPress) */
.nav-item.active {
  background: var(--highlight-color); color: #ffffff;
  font-weight: 600; box-shadow: none; border-radius: 6px;
}

/* Variante flèche (style WordPress) */
.sidebar.hl-arrow .nav-item.active {
  border-radius: 6px 0 0 6px;
}
.sidebar.hl-arrow .nav-item.active::after {
  content: ''; position: absolute;
  right: 0; top: 50%; transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-right: 12px solid var(--bg);
  pointer-events: none; z-index: 2;
}

/* Variante pilule */
.sidebar.hl-pill .nav-item.active { border-radius: 99px; }

/* Variante bordure (style original) */
.sidebar.hl-border .nav-item.active {
  background: color-mix(in srgb, var(--highlight-color) 13%, var(--sidebar-bg));
  color: var(--highlight-color);
  box-shadow: inset 3px 0 0 var(--highlight-color);
  border-radius: 6px;
}
.nav-item-icon   { font-size: .88rem; width: 18px; text-align: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: .6rem; font-weight: 700; padding: .1rem .35rem;
  border-radius: 99px; min-width: 18px; text-align: center;
}

.sidebar-footer { padding: .5rem .6rem .875rem; border-top: 1px solid var(--sidebar-bd); }
.btn-logout-side {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem; border-radius: 6px;
  border: none; background: none; width: 100%; text-align: left;
  color: color-mix(in srgb, var(--sidebar-text) 45%, var(--sidebar-bg)); font-size: .82rem; cursor: pointer;
  transition: all .15s; margin-top: .1rem;
}
.btn-logout-side:hover { background: rgba(239,68,68,.12); color: #ef4444; }

/* ── MAIN ─────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; transition: margin-left .2s ease; }

/* Bouton masquer / afficher le menu latéral */
#sidebar-toggle {
  position: fixed; top: .5rem; left: calc(var(--sidebar-w) - 2.15rem); z-index: 300;
  width: 1.75rem; height: 1.75rem; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--sidebar-bd); border-radius: 7px;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  cursor: pointer; font-size: .95rem; line-height: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); transition: left .2s ease, background .15s;
}
#sidebar-toggle:hover { background: color-mix(in srgb, var(--sidebar-text) 8%, var(--sidebar-bg)); }
#page-app.sidebar-collapsed .sidebar { transform: translateX(-100%); }
#page-app.sidebar-collapsed .main-content { margin-left: 0; }
#page-app.sidebar-collapsed #sidebar-toggle { left: .5rem; }
#page-app.sidebar-collapsed .topbar-left { padding-left: 2.2rem; }

/* Filtres Suivi PA : liste déroulante multi-sélection (cases à cocher) */
.pa-dd { position: relative; }
.pa-dd-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface, #fff); color: var(--text, #374151); font-size: .82rem; cursor: pointer; text-align: left;
}
.pa-dd-btn:hover { border-color: #cbd5e1; }
.pa-dd-btn[aria-expanded="true"] { border-color: #90bce8; box-shadow: 0 0 0 3px rgba(34,113,177,.1); }
.pa-dd-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3, #6b7280); }
.pa-dd-sum.has { color: var(--text, #111827); font-weight: 600; }
.pa-dd-caret { color: #9ca3af; font-size: .7rem; flex-shrink: 0; transition: transform .15s; }
.pa-dd-btn[aria-expanded="true"] .pa-dd-caret { transform: rotate(180deg); }
.pa-dd-panel {
  margin-top: .3rem; border: 1px solid var(--border); border-radius: 8px; padding: .3rem;
  max-height: 12rem; overflow-y: auto; display: flex; flex-direction: column; gap: .1rem; background: var(--surface, #fff);
}
.pa-dd-panel.hidden { display: none; }
.pa-dd-panel .pa-chip {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .32rem .5rem; border: none; border-radius: 6px; background: none;
  font-size: .8rem; color: var(--text, #374151); cursor: pointer; white-space: normal; user-select: none;
}
.pa-dd-panel .pa-chip:hover { background: #f3f4f6; }
.pa-dd-panel .pa-chip.on { background: #eaf2fb; color: #1e5aa0; font-weight: 600; }
.pa-dd-panel .pa-chip > span { flex: 1; text-align: left; }
/* neutralise .field input { width:100%; border; padding } pour les cases à cocher */
.pa-dd-panel .pa-chip input[type="checkbox"] {
  width: auto; flex: 0 0 auto; margin: 0; padding: 0;
  border: 0; border-radius: 0; box-shadow: none; background: none;
  accent-color: #2271B1; cursor: pointer;
}
.pa-dd-panel .pa-chip input[type="checkbox"]:focus { box-shadow: none; }

/* Suivi SIRET : tableau */
.siret-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.siret-table thead th {
  position: sticky; top: 0; z-index: 1; text-align: left;
  padding: .55rem .7rem; background: var(--surface, #fff); color: #6b7280;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid #eef0f3;
}
.siret-table tbody td { padding: .5rem .7rem; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
.siret-table tbody tr:hover { background: #f9fafb; }

/* Suivi PA : bandeau de KPIs cliquables (worklist) */
.pa-kpis { display: flex; flex-wrap: wrap; gap: .6rem; margin: .2rem 0 .5rem; flex-shrink: 0; }
.pa-kpi {
  flex: 1 1 150px; min-width: 140px; border: 1px solid var(--border); border-left-width: 3px;
  border-radius: 10px; padding: .55rem .75rem; background: var(--surface, #fff);
  cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.pa-kpi:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); }
.pa-kpi .k-num { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.pa-kpi .k-lab { font-size: .72rem; color: var(--text-3, #6b7280); margin-top: .25rem; }
.pa-kpi.k-active { box-shadow: 0 0 0 2px rgba(34,113,177,.35); }
.pa-kpi.k-green { border-left-color: #16a34a; } .pa-kpi.k-green .k-num { color: #15803d; }
.pa-kpi.k-amber { border-left-color: #d97706; } .pa-kpi.k-amber .k-num { color: #b45309; }
.pa-kpi.k-red   { border-left-color: #dc2626; } .pa-kpi.k-red   .k-num { color: #b91c1c; }
.pa-kpi.k-slate { border-left-color: #64748b; } .pa-kpi.k-slate .k-num { color: #475569; }

.topbar {
  background: var(--sidebar-bg); border-bottom: 1px solid var(--sidebar-bd);
  padding: .3rem 1.25rem; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.04); min-height: var(--topbar-h);
}
.topbar-left { display: flex; align-items: center; gap: .5rem; }
.topbar-title { font-size: .875rem; font-weight: 700; color: var(--sidebar-text); }
.topbar-dot   { color: color-mix(in srgb, var(--sidebar-text) 40%, var(--sidebar-bg)); font-weight: 300; font-size: .9rem; }
.topbar-sub   { font-size: .78rem; color: color-mix(in srgb, var(--sidebar-text) 40%, var(--sidebar-bg)); }

/* Barre de recherche + filtres */
.sticky-search {
  flex-shrink: 0; background: var(--bg);
  padding: .6rem 1.25rem; border-bottom: 1px solid var(--border-lt);
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}
.sticky-search .toolbar { margin-bottom: 0; }

.view-body { flex: 1; overflow: hidden; min-height: 0; padding: 1rem 1.25rem 1.5rem; display: flex; flex-direction: column; }

.view { display: none; }
.view.active { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* ── TOOLBAR ─────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.search-wrap { flex: 1; min-width: 200px; position: relative; }
.search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; font-size: .85rem; }
.search-box {
  width: 100%; padding: .5rem .8rem .5rem 2.2rem;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .855rem; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.search-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
/* Recherche Mandats : place pour la croix d'effacement + masque la croix native */
#m-search { padding-right: 2rem; }
#m-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
#m-search-clear:hover { background: #d1d5db; color: #374151; }

/* Filtres statut */
.status-filters { display: flex; gap: .25rem; }
.sf-btn {
  padding: .3rem .65rem; border-radius: 99px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: .75rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: all .12s; font-family: inherit;
}
.sf-btn:hover { border-color: var(--primary-mid); color: var(--primary); }
.sf-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sf-btn[data-statut="en_cours"].active  { background: #2563eb; border-color: #2563eb; }
.sf-btn[data-statut="en_attente"].active{ background: #d97706; border-color: #d97706; }
.sf-btn[data-statut="cloture"].active   { background: #6b7280; border-color: #6b7280; }

/* Scope toggle admin */
.scope-toggle { display: flex; border: 1.5px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.scope-btn {
  padding: .3rem .7rem; border: none; background: none;
  font-size: .78rem; font-weight: 500; color: var(--text-2);
  cursor: pointer; transition: all .12s; font-family: inherit; white-space: nowrap;
}
.scope-btn:hover { background: var(--bg); }
.scope-btn.active { background: var(--primary-lt); color: var(--primary); }

.view-toggle { display: flex; border: 1.5px solid var(--border); border-radius: var(--r-sm); overflow: hidden; flex-shrink: 0; }
.view-toggle-btn { background: none; border: none; padding: .38rem .6rem; cursor: pointer; font-size: .9rem; color: var(--text-3); transition: all .15s; line-height: 1; }
.view-toggle-btn:hover  { background: var(--bg); color: var(--text); }
.view-toggle-btn.active { background: var(--primary-lt); color: var(--primary); }

/* ═══════════════════════════════════════════
   BADGES STATUT
═══════════════════════════════════════════ */
.statut-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .7rem; font-weight: 600; padding: .18rem .55rem;
  border-radius: 99px; white-space: nowrap;
}
.statut-en_cours  { background: #dbeafe; color: #1e40af; }
.statut-en_attente{ background: #fef3c7; color: #92400e; }
.statut-cloture   { background: #f1f5f9; color: #475569; }

/* ═══════════════════════════════════════════
   VUE LISTE
═══════════════════════════════════════════ */
#dossiers-list { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.dl-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; display: flex; flex-direction: column; flex: 1; min-height: 0; }

.dl-header {
  display: grid;
  grid-template-columns: 28px 2fr 1.1fr 1.1fr 90px 100px 90px 80px;
  gap: 0 .75rem; padding: .45rem 1rem;
  background: var(--bg); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dl-rows-wrapper { flex: 1; overflow-y: auto; min-height: 0; }
.dl-header span {
  font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .055em; color: var(--text-3);
  white-space: nowrap; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: .25rem;
}
.dl-header span:hover { color: var(--primary); }
.dl-header span.sort-active { color: var(--primary); }
.sort-arr { font-size: .6rem; opacity: .6; }

.dl-row {
  display: grid;
  grid-template-columns: 28px 2fr 1.1fr 1.1fr 90px 100px 90px 80px;
  gap: 0 .75rem; padding: .5rem 1rem;
  border-bottom: 1px solid var(--border-lt); align-items: center;
  transition: background .1s; cursor: pointer;
}
.dl-row:last-child { border-bottom: none; }
/* Dossier exclu de l'envoi de mandat : ligne atténuée */
.dl-row.dl-excluded { opacity: .58; background: #fafafa; }
.dl-row.dl-excluded:hover { opacity: .8; }
.dl-row:hover { background: #f8f9ff; }
.dl-row:hover .dl-actions { opacity: 1; pointer-events: auto; }

.dl-av {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.av-0{background:linear-gradient(135deg,#667eea,#764ba2);}
.av-1{background:linear-gradient(135deg,#4facfe,#00f2fe);color:#0f172a}
.av-2{background:linear-gradient(135deg,#43e97b,#38f9d7);color:#0f172a}
.av-3{background:linear-gradient(135deg,#fa709a,#fee140);}
.av-4{background:linear-gradient(135deg,#a18cd1,#fbc2eb);}
.av-5{background:linear-gradient(135deg,#f093fb,#f5576c);}
.av-6{background:linear-gradient(135deg,#4481eb,#04befe);}
.av-7{background:linear-gradient(135deg,#0ba360,#3cba92);}
.av-8{background:linear-gradient(135deg,#f7971e,#ffd200);color:#0f172a}
.av-9{background:linear-gradient(135deg,#ee0979,#ff6a00);}

.dl-nom-cell { min-width: 0; }
.dl-nom { font-size: .855rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: .4rem; }
.dl-sub { font-size: .72rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; display: flex; gap: .3rem; align-items: center; }

.chip { display: inline-flex; align-items: center; font-size: .63rem; font-weight: 600; padding: .1rem .38rem; border-radius: 4px; white-space: nowrap; }
.chip-siren { background: var(--primary-lt); color: var(--primary); }
.chip-forme { background: #f1f5f9; color: var(--text-2); }
.chip-naf   { background: #f0fdf4; color: #166534; }

.dl-cell { font-size: .815rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-cell.muted { color: var(--text-3); font-size: .78rem; }

.dl-comp { display: flex; align-items: center; gap: .4rem; }
.dl-mini-av {
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg,#06b6d4,#0891b2);
  color: #fff; font-size: .58rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.dl-actions { display: flex; gap: .2rem; justify-content: flex-end; opacity: 0; transition: opacity .12s; pointer-events: none; }

/* ═══════════════════════════════════════════
   VUE GRILLE
═══════════════════════════════════════════ */
.dossiers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .875rem; }
.dossier-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.1rem; box-shadow: var(--sh); transition: all .2s; position: relative; overflow: hidden; cursor: pointer;
}
.dossier-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; opacity: 0; transition: opacity .2s; }
.dossier-card:hover { border-color: var(--primary-mid); box-shadow: var(--sh-md); transform: translateY(-2px); }
.dossier-card:hover::before { opacity: 1; background: linear-gradient(90deg, var(--primary), #06b6d4); }
.dossier-header { display: flex; align-items: flex-start; gap: .65rem; margin-bottom: .6rem; }
.dossier-avatar { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.dossier-nom { font-size: .875rem; font-weight: 600; }
.dossier-chips { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .25rem; }
.dossier-contact { font-size: .78rem; color: var(--text-2); display: flex; align-items: center; gap: .3rem; margin-bottom: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dossier-footer { display: flex; align-items: center; gap: .4rem; margin-top: .75rem; padding-top: .65rem; border-top: 1px solid var(--border-lt); }
.dossier-date { font-size: .7rem; color: var(--text-3); flex: 1; }
.dossier-tags { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .3rem; }
.tag { font-size: .67rem; font-weight: 500; background: #f1f5f9; color: var(--text-2); border: 1px solid var(--border); padding: .12rem .42rem; border-radius: 4px; }

/* ═══════════════════════════════════════════
   PAGINATION
═══════════════════════════════════════════ */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem; border-top: 1px solid var(--border);
  background: var(--bg); border-radius: 0 0 var(--r) var(--r);
  flex-wrap: wrap; gap: .5rem; flex-shrink: 0;
}
.pagination-info { font-size: .78rem; color: var(--text-3); }
.pagination-info strong { color: var(--text-2); }
.pagination-controls { display: flex; align-items: center; gap: .25rem; }
.pg-btn {
  min-width: 30px; height: 30px; padding: 0 .5rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text-2);
  font-size: .8rem; font-weight: 500; cursor: pointer; transition: all .12s; font-family: inherit;
}
.pg-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }
.pg-btn:disabled { opacity: .35; cursor: default; }
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-ellipsis { font-size: .8rem; color: var(--text-3); padding: 0 .2rem; }
.page-size-select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: .3rem .5rem; font-size: .78rem; color: var(--text-2);
  background: var(--surface); cursor: pointer; outline: none; font-family: inherit;
}
.page-size-select:focus { border-color: var(--primary); }

/* ═══════════════════════════════════════════
   STATS ADMIN
═══════════════════════════════════════════ */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: .875rem; margin-bottom: 1.25rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1rem 1.1rem; display: flex; align-items: center; gap: .875rem; box-shadow: var(--sh);
}
.stat-icon { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.stat-icon.blue  { background: #eff6ff; }
.stat-icon.green { background: #f0fdf4; }
.stat-icon.red   { background: #fef2f2; }
.stat-num   { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .73rem; color: var(--text-3); margin-top: 2px; }

/* ═══════════════════════════════════════════
   TABLE ADMIN
═══════════════════════════════════════════ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }
th { padding: .6rem 1.1rem; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); text-align: left; border-bottom: 1px solid var(--border); }
td { padding: .8rem 1.1rem; font-size: .855rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
.role-badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .7rem; font-weight: 600; padding: .17rem .55rem; border-radius: 99px; }
.role-admin         { background: #fef3c7; color: #92400e; }
.role-collaborateur { background: #dbeafe; color: #1e40af; }

/* ── Gestion des dossiers (admin) — layout parent/enfant ── */
#tab-dossiers-admin, #tab-logs { padding: 0 !important; }
.gd-layout {
  display: flex; height: 100%; min-height: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--sh);
}
/* Panneau gauche */
.gd-left { width: 200px; flex-shrink: 0; border-right: 1px solid var(--border); overflow-y: auto; }
.gd-left-header {
  padding: .55rem .9rem; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
  border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0;
}
.gd-owner-item {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  padding: .62rem .9rem; font-size: .82rem; cursor: pointer;
  border-bottom: 1px solid var(--border-lt);
}
.gd-owner-item:hover { background: var(--bg); }
.gd-owner-item.active {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary); font-weight: 600;
  border-left: 3px solid var(--primary); padding-left: calc(.9rem - 3px);
}
.gd-owner-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.gd-owner-count {
  font-size: .68rem; font-weight: 600; padding: .1rem .4rem; border-radius: 99px;
  white-space: nowrap; flex-shrink: 0; background: var(--border); color: var(--text-3);
}
.gd-owner-item.active .gd-owner-count { background: var(--primary); color: #fff; }
/* Panneau droit */
.gd-right { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: .875rem; gap: .7rem; overflow-y: auto; }
.gd-toolbar { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.gd-count { font-size: .8rem; color: var(--text-3); white-space: nowrap; }
.gd-table-wrap { flex: 1; overflow-y: auto; }
.gd-table-wrap table { table-layout: fixed; }
.gd-table-wrap td, .gd-table-wrap th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-check { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
tr.gd-selected { background: #eef2ff !important; }

/* ═══════════════════════════════════════════
   ONGLETS ADMIN
═══════════════════════════════════════════ */
.admin-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; padding: 0 1.25rem;
}
.admin-tab {
  padding: .65rem 1rem; font-size: .82rem; font-weight: 500;
  border: none; background: none; cursor: pointer; color: var(--text-3);
  border-bottom: 2px solid transparent; transition: all .15s;
  font-family: inherit; white-space: nowrap; margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text-2); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: flex; flex: 1; flex-direction: column; min-height: 0; }
/* onglets qui scrollent librement */
#tab-collaborateurs.active,
#tab-activite.active,
#tab-parametres.active { overflow-y: auto; }
/* onglet dossiers : ne scrolle pas — la gd-layout gère l'espace */
#tab-dossiers-admin.active, #tab-logs.active { overflow: hidden; padding: 0 !important; }
#view-admin .view-body { overflow: hidden; }

/* ═══════════════════════════════════════════
   JOURNAL D'ACTIVITÉ
═══════════════════════════════════════════ */
/* ── Logs dossiers ─────────────────────────────── */
.logs-toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-shrink: 0; }
.logs-filters { display: flex; gap: .35rem; }
.log-filter-btn {
  padding: .3rem .75rem; border-radius: 99px; font-size: .75rem; font-weight: 600;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.log-filter-btn:hover { background: var(--bg); }
.log-filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.logs-status { font-size: .75rem; color: var(--text-3); }
.logs-list {
  flex: 1; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh);
}
.log-row {
  display: grid; grid-template-columns: 28px 90px 80px 1fr auto;
  align-items: center; gap: .75rem;
  padding: .55rem 1rem; border-bottom: 1px solid var(--border-lt);
  font-size: .8rem;
}
.log-row:last-child { border-bottom: none; }
.log-icon { width: 26px; height: 26px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .75rem; }
.log-time { font-size: .72rem; color: var(--text-3); white-space: nowrap; }
.log-user { font-size: .75rem; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-detail { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-siren { font-family: monospace; font-size: .72rem; color: var(--text-3); white-space: nowrap; }

.activity-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .875rem; }
.section-title { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.activity-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh); }
.activity-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .65rem 1rem; border-bottom: 1px solid var(--border-lt);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.act-create { background: #dcfce7; }
.act-update { background: #dbeafe; }
.act-delete { background: #fee2e2; }
.activity-body { flex: 1; min-width: 0; }
.activity-desc { font-size: .82rem; color: var(--text); }
.activity-meta { font-size: .72rem; color: var(--text-3); margin-top: 2px; }
.act-user { font-weight: 600; color: var(--text-2); }

/* ═══════════════════════════════════════════
   VOLET SOCIAL
═══════════════════════════════════════════ */
#view-social .dl-header,
#view-social .dl-row {
  grid-template-columns: 28px 2fr 1.1fr 1.3fr 1fr 1fr 88px 60px;
}
#social-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.social-filters {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem 1rem .45rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.filter-group { display: flex; gap: .3rem; flex-wrap: wrap; }
.filter-sep   { width: 1px; height: 18px; background: var(--border); align-self: center; }
.filter-pill {
  padding: .2rem .7rem;
  font-size: .76rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--bg);
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1.5;
}
.filter-pill:hover   { border-color: var(--primary); color: var(--primary); }
.filter-pill.active  { background: var(--primary); border-color: var(--primary); color: #fff; }
.cov-badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}
.cov-cabinet { background: #dcfce7; color: #166534; }
.cov-client  { background: #dbeafe; color: #1d4ed8; }
.cov-none    { color: var(--text-3); }
.social-toolbar-count {
  margin-left: auto;
  font-size: .78rem;
  color: var(--text-3);
  white-space: nowrap;
  padding: .2rem .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
}
.social-layout {
  display: flex; height: 100%; min-height: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--sh);
}

/* Panneau gauche dossiers */
.social-left { width: 230px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.social-left-search { padding: .6rem .75rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.social-left-search .search-box { border: none; background: transparent; outline: none; font-size: .82rem; width: 100%; }
#social-dossiers-list { flex: 1; overflow-y: auto; }

.social-dossier-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem .85rem; font-size: .82rem; cursor: pointer;
  border-bottom: 1px solid var(--border-lt);
}
.social-dossier-item:hover { background: var(--bg); }
.social-dossier-item.active { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); padding-left: calc(.85rem - 3px); }
.social-dossier-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.social-cred-dot { font-size: .6rem; line-height: 1; }
.social-cred-dot.has-cred { color: #16a34a; }
.social-cred-dot.no-cred  { color: var(--border); }

/* Panneau droit */
.social-right { flex: 1; min-width: 0; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.social-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--text-3); gap: .75rem; }
.social-empty-icon { font-size: 2.5rem; }
.social-empty p { font-size: .9rem; }

.social-dossier-header { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: .75rem 1rem; }
.social-dossier-header .sdh-nom { font-size: 1rem; font-weight: 700; color: var(--text); }
.social-dossier-header .sdh-meta { font-size: .78rem; color: var(--text-3); margin-top: 2px; }

.social-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .social-cards { grid-template-columns: 1fr; } }

.social-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.social-card-header { display: flex; align-items: flex-start; justify-content: space-between; padding: .85rem 1rem .6rem; border-bottom: 1px solid var(--border-lt); }
.social-card-title { font-size: .87rem; font-weight: 700; color: var(--text); }
.social-card-sub   { font-size: .72rem; color: var(--text-3); margin-top: 2px; }
.social-card-body  { padding: .85rem 1rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.social-card-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .25rem; }

/* Password toggle */
.pwd-wrap { display: flex; position: relative; }
.pwd-wrap .input-text { flex: 1; padding-right: 2.2rem; }
.btn-pwd-toggle { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: .85rem; color: var(--text-3); padding: 0; }

/* Champ générique */
.field { display: flex; flex-direction: column; gap: .25rem; }
.field label { font-size: .75rem; font-weight: 600; color: var(--text-2); }
.input-text { padding: .5rem .7rem; border: 1.5px solid var(--border); border-radius: var(--r-sm); font-size: .855rem; outline: none; font-family: inherit; color: var(--text); background: var(--surface); }
.input-text:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
textarea.input-text { resize: vertical; }
.field-msg { font-size: .75rem; flex: 1; }
.field-msg.ok  { color: var(--success); }
.field-msg.err { color: var(--danger);  }
.btn-screenshot { display: inline-block; margin-left: .35rem; font-size: .9rem; text-decoration: none; opacity: .85; }
.btn-screenshot:hover { opacity: 1; }

/* ═══════════════════════════════════════════
   PARAMÈTRES SCRAPE
═══════════════════════════════════════════ */
#tab-scrape.active { overflow: hidden; padding: 0 !important; }
.scrape-layout { display: flex; height: 100%; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--sh); }
#scrape-panel-client { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#scrape-panel-tasks   { flex: 1; min-height: 0; overflow-y: auto; }
#scrape-panel-cabinet { flex: 1; min-height: 0; overflow-y: auto; }
.settings-card-title { font-size: .9rem; font-weight: 700; margin-bottom: .2rem; }
.settings-card-desc  { font-size: .79rem; color: var(--text-3); margin-bottom: .9rem; }
.scrape-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.scrape-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
.scrape-task-bar { display: flex; align-items: center; gap: .75rem; }
.scrape-sync-status { font-size: .8rem; color: var(--text-3); }
.scrape-sync-result { margin-top: .75rem; padding: .75rem 1rem; border-radius: var(--r-sm); font-size: .82rem; background: var(--bg); border: 1px solid var(--border); }
.scrape-sync-result.ok  { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.scrape-sync-result.warn{ background: #fefce8; border-color: #fde68a; color: #854d0e; }
.scrape-sync-result.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ── Tâches scrape ── */
.task-card            { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1rem; margin-top: .75rem; background: var(--bg); }
.task-card-header     { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.task-card-info       { flex: 1; }
.task-card-name       { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.task-card-desc       { font-size: .78rem; color: var(--text-3); line-height: 1.4; }
.task-card-btns       { display: flex; gap: .5rem; flex-shrink: 0; align-items: center; }
.btn-sm               { padding: .25rem .75rem; font-size: .8rem; }
.btn-danger           { background: #dc2626; color: #fff; border: none; border-radius: var(--r-sm); cursor: pointer; font-weight: 500; }
.btn-danger:hover     { background: #b91c1c; }
.jobs-table           { width: 100%; font-size: .82rem; border-collapse: collapse; }
.jobs-table th        { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-3); font-weight: 600; padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--border); }
.jobs-table td        { padding: .45rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.jobs-table tr:last-child td { border-bottom: none; }
.job-badge            { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.job-badge.running    { background: #eff6ff; color: #1d4ed8; }
.job-badge.done       { background: #f0fdf4; color: #166534; }
.job-badge.error      { background: #fef2f2; color: #991b1b; }
.job-badge.cancelled  { background: #f3f4f6; color: #6b7280; }

/* ═══════════════════════════════════════════
   PARAMÈTRES
═══════════════════════════════════════════ */
.settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.25rem 1.5rem; box-shadow: var(--sh); max-width: 680px; margin-bottom: 1rem;
}
.settings-card:last-child { margin-bottom: 0; }
.settings-title { font-size: .9rem; font-weight: 700; margin-bottom: .35rem; }
.settings-desc  { font-size: .8rem; color: var(--text-3); margin-bottom: 1rem; }
.settings-row { display: flex; align-items: center; gap: .75rem; }
.settings-row label { font-size: .82rem; font-weight: 500; white-space: nowrap; }
.settings-input { width: 80px; padding: .45rem .6rem; border: 1.5px solid var(--border); border-radius: var(--r-sm); font-size: .855rem; outline: none; font-family: inherit; }
.settings-input:focus { border-color: var(--primary); }
.settings-ok  { color: var(--success); font-size: .8rem; margin-top: .5rem; }
.settings-err { color: var(--danger);  font-size: .8rem; margin-top: .5rem; }

/* ═══════════════════════════════════════════
   DRAWER DOSSIER
═══════════════════════════════════════════ */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15,23,42,.3); backdrop-filter: blur(2px);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 301;
  width: 420px; max-width: 100vw;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
  animation: slideInRight .2s ease;
}
@keyframes slideInRight { from { transform: translateX(100%) } to { transform: translateX(0) } }

.drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1rem 1.1rem .9rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title { font-size: .95rem; font-weight: 700; color: var(--text); }
.drawer-sub   { font-size: .75rem; color: var(--text-3); margin-top: 2px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; }

.drawer-statut-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .875rem; }

.drawer-section { margin-bottom: 1.1rem; }
.drawer-field { display: flex; gap: .5rem; margin-bottom: .4rem; align-items: flex-start; }
.df-label { font-size: .72rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; min-width: 110px; flex-shrink: 0; padding-top: .05rem; }
.df-val   { font-size: .82rem; color: var(--text); }

.drawer-notes-text { font-size: .82rem; color: var(--text-2); white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border-lt); border-radius: var(--r-sm); padding: .6rem .8rem; line-height: 1.6; }

/* Journal de notes dans le drawer */
.note-add-wrap { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .75rem; }
.note-input {
  width: 100%; padding: .55rem .8rem; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: .82rem; outline: none; resize: vertical;
  font-family: inherit; transition: border-color .15s;
}
.note-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.btn-sm { padding: .35rem .85rem; font-size: .8rem; align-self: flex-end; }

.notes-list { display: flex; flex-direction: column; gap: .4rem; }
.note-item {
  background: var(--bg); border: 1px solid var(--border-lt);
  border-radius: var(--r-sm); padding: .55rem .75rem;
  position: relative;
}
.note-item:hover .note-delete { opacity: 1; }
.note-body   { font-size: .82rem; color: var(--text); white-space: pre-wrap; line-height: 1.5; }
.note-footer { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; }
.note-author { font-size: .7rem; font-weight: 600; color: var(--primary); }
.note-date   { font-size: .68rem; color: var(--text-3); }
.note-delete {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: .78rem; opacity: 0; transition: opacity .12s;
  padding: .1rem .3rem; border-radius: 4px;
}
.note-delete:hover { color: var(--danger); }

.drawer-footer {
  padding: .75rem 1.1rem; border-top: 1px solid var(--border);
  display: flex; gap: .6rem; justify-content: flex-end; flex-shrink: 0;
  background: var(--surface);
}

/* ═══════════════════════════════════════════
   EMPTY
═══════════════════════════════════════════ */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5rem 2rem; text-align: center; color: var(--text-3); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-2); margin-bottom: .35rem; }
.empty-state p  { font-size: .84rem; }

/* ═══════════════════════════════════════════
   BOUTONS
═══════════════════════════════════════════ */
.btn-primary {
  display: inline-flex; align-items: center; gap: .35rem;
  background: linear-gradient(135deg,#6366f1,#4f46e5); color: #fff;
  border: none; border-radius: var(--r-sm); padding: .55rem 1.05rem;
  font-size: .845rem; font-weight: 500; cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 8px rgba(79,70,229,.3); transition: all .18s; white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(79,70,229,.4); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: .53rem 1.05rem; font-size: .845rem;
  font-weight: 500; cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-secondary:hover { background: var(--bg); border-color: var(--primary-mid); }
.btn-danger {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--danger); color: #fff; border: none; border-radius: var(--r-sm);
  padding: .55rem 1.05rem; font-size: .845rem; font-weight: 500; cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-danger:hover { background: var(--danger-dk); }

/* Notifications globales (toast + confirmation) — utilisées hors onglet Mandats */
.app-toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: .7rem 1.1rem; border-radius: 8px; font-size: .85rem; opacity: 0; transition: .25s; z-index: 99999; pointer-events: none; max-width: 80vw; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast.err  { background: #b91c1c; }
.app-confirm-box    { max-width: 440px; text-align: center; padding: 1.7rem 1.6rem; }
.app-confirm-icon   { width: 54px; height: 54px; border-radius: 50%; background: #eff6fd; color: #2271B1; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto .9rem; }
.app-confirm-icon.danger { background: #fef2f2; color: #dc2626; }
.app-confirm-title  { font-size: 1.1rem; margin: 0 0 .45rem; }
.app-confirm-msg    { font-size: .9rem; color: #4b5563; margin: 0 0 1.2rem; white-space: pre-line; line-height: 1.55; text-align: left; }
.app-confirm-actions { display: flex; gap: .6rem; justify-content: center; }
.btn-icon {
  display: inline-flex; align-items: center; gap: .25rem;
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: .3rem .6rem; font-size: .775rem; color: var(--text-3);
  cursor: pointer; font-family: inherit; transition: all .12s; white-space: nowrap;
}
.btn-icon:hover { background: var(--bg); color: var(--text); border-color: var(--primary-mid); }
.btn-icon.edit:hover   { background: var(--primary-lt); color: var(--primary); border-color: var(--primary-mid); }
.btn-icon.delete:hover { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* ═══════════════════════════════════════════
   FORMS
═══════════════════════════════════════════ */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .79rem; font-weight: 500; margin-bottom: .3rem; color: var(--text); }
.field input, .field textarea, .field select {
  width: 100%; padding: .55rem .8rem;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .855rem; outline: none; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.field textarea { resize: vertical; min-height: 72px; }
.req { color: var(--danger); }
.fields-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.field-divider { text-align: center; font-size: .72rem; color: var(--text-3); margin: .1rem 0 .75rem; }
.error-msg { color: #b91c1c; font-size: .79rem; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: .45rem .7rem; margin-top: .4rem; }
/* ── Palette de couleur interface ─────────────── */
.color-palette      { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.text-color-palette { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.text-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: all .15s; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.text-swatch:hover  { transform: scale(1.15); }
.text-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.2); }
.settings-palette-label { font-size: .74rem; font-weight: 600; color: var(--text-2); margin-top: .75rem; margin-bottom: .15rem; display: block; }
.color-swatch {
  position: relative; width: 64px; height: 40px; border-radius: 7px;
  border: 2px solid transparent; cursor: pointer; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: .2rem; transition: all .13s;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.color-swatch:hover  { border-color: var(--primary-mid); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.14); }
.color-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.18); }
.swatch-check {
  position: absolute; top: 3px; right: 4px;
  font-size: .66rem; font-weight: 700; color: var(--primary);
  display: none;
}
.color-swatch.active .swatch-check { display: block; }
.swatch-name {
  font-size: .52rem; color: #374151; font-weight: 500;
  background: rgba(255,255,255,.8); padding: .05rem .25rem;
  border-radius: 3px; white-space: nowrap; pointer-events: none;
}
.font-size-btns { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.fs-btn {
  padding: .35rem .85rem; border-radius: 6px; font-family: inherit; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-2);
  font-weight: 500; transition: all .12s;
}
.fs-btn:hover  { border-color: var(--primary-mid); color: var(--primary); }
.fs-btn.active { background: var(--primary-lt); color: var(--primary); border-color: var(--primary-mid); font-weight: 600; }

.hl-color-palette { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; }
.hl-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: all .15s; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.hl-swatch:hover  { transform: scale(1.18); }
.hl-swatch.active { border-color: #fff; box-shadow: 0 0 0 3px currentColor; outline: none; }

.hl-style-btns { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.hl-style-btn {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: .5rem .8rem; border-radius: 8px; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font-family: inherit; transition: all .13s;
  min-width: 72px;
}
.hl-style-preview {
  width: 52px; height: 20px; border-radius: 4px; display: flex;
  align-items: center; padding: 0 6px; gap: 4px; flex-shrink: 0;
}
.hl-style-preview span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.7); flex-shrink: 0; }
.hl-style-preview em   { font-style: normal; font-size: .55rem; color: #fff; font-weight: 600; white-space: nowrap; }
.hl-style-btn .label { font-size: .7rem; color: var(--text-2); font-weight: 500; }
.hl-style-btn:hover  { border-color: var(--primary-mid); }
.hl-style-btn.active { border-color: var(--primary); background: var(--primary-lt); }
.hl-style-btn.active .label { color: var(--primary); font-weight: 600; }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   MODALS
═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 1rem; animation: fadeIn .15s ease;
}
@keyframes fadeIn  { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: translateY(0) } }
.modal {
  background: var(--surface); border-radius: 16px;
  padding: 1.75rem; width: 100%; max-width: 520px;
  box-shadow: var(--sh-lg); animation: slideUp .2s ease;
  border: 1px solid var(--border); max-height: 92vh; overflow-y: auto;
}
.modal-sm { max-width: 400px; }
.modal-import-box { max-width: 600px; }

/* ── Import ─────────────────────────────────────── */
.import-textarea {
  width: 100%; min-height: 180px; padding: .6rem .8rem;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .84rem; font-family: 'SF Mono', 'Consolas', monospace;
  outline: none; resize: vertical; color: var(--text); background: var(--surface);
  line-height: 1.6;
}
.import-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.import-hint { font-size: .76rem; color: var(--text-3); line-height: 1.7; margin-top: .5rem; }
.import-hint code { background: var(--border-lt); padding: .1rem .3rem; border-radius: 3px; font-family: monospace; }

.import-progress-wrap { padding: .5rem 0 1.5rem; }
.import-progress-bar {
  height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: .75rem;
}
#import-progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #6366f1, #4f46e5);
  border-radius: 99px; transition: width .3s ease;
}
.import-progress-text { font-size: .84rem; color: var(--text-2); text-align: center; }

.import-summary {
  display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.import-stat {
  flex: 1; min-width: 80px; padding: .6rem .8rem; border-radius: var(--r-sm);
  text-align: center; border: 1px solid var(--border);
}
.import-stat .is-num  { font-size: 1.5rem; font-weight: 700; display: block; line-height: 1.2; }
.import-stat .is-lbl  { font-size: .68rem; color: var(--text-3); font-weight: 500; }
.import-stat.ok     { background: #f0fdf4; border-color: #bbf7d0; }
.import-stat.ok .is-num { color: #16a34a; }
.import-stat.skip   { background: #fefce8; border-color: #fde68a; }
.import-stat.skip .is-num { color: #ca8a04; }
.import-stat.error  { background: #fef2f2; border-color: #fecaca; }
.import-stat.error .is-num { color: #dc2626; }

.import-results-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.import-result-row {
  display: grid; grid-template-columns: 100px 1fr auto;
  align-items: center; gap: .75rem;
  padding: .45rem .75rem; border-bottom: 1px solid var(--border-lt);
  font-size: .8rem;
}
.import-result-row:last-child { border-bottom: none; }
.ir-siren { font-family: monospace; font-weight: 600; color: var(--text-2); }
.ir-nom   { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-badge { font-size: .68rem; font-weight: 600; padding: .15rem .5rem; border-radius: 99px; white-space: nowrap; }
.ir-ok    { background: #dcfce7; color: #166534; }
.ir-api   { background: #dbeafe; color: #1e40af; }
.ir-skip  { background: #fef9c3; color: #854d0e; }
.ir-err   { background: #fee2e2; color: #991b1b; }
.modal-header { margin-bottom: 1.4rem; }
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-header p  { font-size: .79rem; color: var(--text-3); margin-top: 2px; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════
   SIREN / AUTOCOMPLETE
═══════════════════════════════════════════ */
.siren-input-wrap { position: relative; }
.siren-input-wrap input { padding-right: 150px; }
.siren-loader { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: .35rem; font-size: .75rem; color: var(--text-3); }
.spinner { width: 13px; height: 13px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg) } }
.siren-badge { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); font-size: .7rem; font-weight: 600; padding: .15rem .5rem; border-radius: 99px; white-space: nowrap; }
.siren-ok  { background: #dcfce7; color: #166534; }
.siren-nok { background: #fee2e2; color: #991b1b; }
.autocomplete-wrap { position: relative; }
.autocomplete-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1.5px solid var(--primary); border-radius: var(--r); box-shadow: var(--sh-md); z-index: 300; overflow: hidden; max-height: 300px; overflow-y: auto; }
.autocomplete-item { padding: .6rem .875rem; cursor: pointer; border-bottom: 1px solid var(--border-lt); transition: background .1s; }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-lt); }
.ac-nom    { font-size: .855rem; font-weight: 600; }
.ac-detail { font-size: .73rem; color: var(--text-3); margin-top: 2px; display: flex; gap: .4rem; flex-wrap: wrap; }
.ac-siren  { font-weight: 700; color: var(--primary); }
.autocomplete-empty { padding: .7rem .875rem; font-size: .8rem; color: var(--text-3); text-align: center; }

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  #sidebar-toggle { display: none; }
  .dossiers-grid { grid-template-columns: 1fr; }
  .dl-row, .dl-header { grid-template-columns: 28px 1fr 80px; }
  .fields-row { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .status-filters { display: none; }
}


/* Menu « Actions Sage » (page Statut accès Sage) */
.acts-wrap { position: relative; }
.acts-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; min-width: 360px;
  background: #fff; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; padding: .3rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .15); }
.acts-menu button { display: flex; width: 100%; gap: .4rem; align-items: baseline; text-align: left; border: 0; background: none;
  padding: .45rem .6rem; border-radius: 7px; font: inherit; font-size: .85rem; cursor: pointer; color: #1f2937; }
.acts-menu button:hover:not(:disabled) { background: #f1f5f9; }
.acts-menu button:disabled { color: #9ca3af; cursor: default; }
.acts-menu small { margin-left: auto; color: #9ca3af; font-size: .72rem; }
.acts-menu hr { border: 0; border-top: 1px solid #eef2f7; margin: .25rem 0; }

/* ── Page « Campagne PA » ───────────────────────────────────────────────── */
.camp-body { overflow: auto; gap: 14px; padding-bottom: 20px; }
.camp-hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 20px; box-shadow: var(--sh); }
.camp-label { font-size: .82rem; color: var(--text-2); font-weight: 600; }
.camp-hero-value { font-size: 52px; font-weight: 700; line-height: 1.05; color: var(--text); margin-top: 4px; }
.camp-hero-of { font-size: 20px; font-weight: 500; color: var(--text-3); margin-left: 8px; }
.camp-sub { font-size: .78rem; color: var(--text-3); margin: 2px 0 0; }
.camp-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 1100px) { .camp-grid { grid-template-columns: 1fr; } }
.camp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 18px; box-shadow: var(--sh); }
.camp-card h3 { margin: 0; font-size: .95rem; color: var(--text); }
.camp-funnel { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.camp-step { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) 7.5rem; align-items: center; gap: 12px; padding: 3px 0; border-radius: 6px; outline: none; }
.camp-step:hover .camp-fill, .camp-step:focus-visible .camp-fill { background: var(--primary-dk); }
.camp-step:focus-visible { box-shadow: 0 0 0 2px var(--primary-mid); }
.camp-step-label { font-size: .82rem; color: var(--text-2); }
.camp-track { position: relative; height: 14px; background: var(--primary-lt); border-radius: 0 4px 4px 0; }
.camp-fill { position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: 0 4px 4px 0; min-width: 2px; }
.camp-step-val { font-size: .85rem; color: var(--text); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.camp-step-val small { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.camp-table-toggle { margin-top: 10px; font-size: .78rem; color: var(--text-2); }
.camp-table-toggle table { border-collapse: collapse; margin-top: 6px; width: 100%; }
.camp-table-toggle td, .camp-table-toggle th { padding: 3px 8px; border-bottom: 1px solid var(--border-lt); text-align: left; font-variant-numeric: tabular-nums; }
.camp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.camp-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--sh); }
.camp-kpi-label { font-size: .76rem; color: var(--text-2); }
.camp-kpi-value { font-size: 26px; font-weight: 600; color: var(--text); margin-top: 2px; }
.camp-kpi-sub { font-size: .72rem; color: var(--text-3); margin-top: 2px; }
.camp-todo { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.camp-todo-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border-lt); border-radius: var(--r-sm); font-size: .82rem; color: var(--text); }
.camp-todo-item .camp-ico { flex: 0 0 auto; }
.camp-todo-item span.t { flex: 1; min-width: 0; }
.camp-todo-item button { flex: 0 0 auto; padding: .2rem .6rem; font-size: .76rem; }
.camp-todo-ok { font-size: .82rem; color: var(--text-2); padding: 8px 0; }
.camp-tip { position: fixed; z-index: 80; pointer-events: none; background: #0f172a; color: #f8fafc; font-size: .76rem; line-height: 1.4; padding: 6px 9px; border-radius: 6px; box-shadow: var(--sh-md); max-width: 280px; }
#camp-jobs table { width: 100%; border-collapse: collapse; font-size: .8rem; margin-top: 8px; }
#camp-jobs td, #camp-jobs th { padding: 4px 8px; border-bottom: 1px solid var(--border-lt); text-align: left; }
#camp-jobs th { color: var(--text-2); font-weight: 600; }

/* ── Page « Dossiers » (Sage Active) ────────────────────────────────────── */
.act-body { gap: 10px; }
.act-info { padding: .55rem .85rem; background: #eff6fd; border: 1px solid #cfe3fb; border-radius: 8px; font-size: .8rem; color: #1e5aa0; flex-shrink: 0; }
.act-msg { padding: .5rem .85rem; background: #fff7ed; border: 1px solid #fde9d3; border-radius: 8px; font-size: .82rem; color: #92400e; flex-shrink: 0; }
.act-tools { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.act-tools input { flex: 1; min-width: 240px; font-size: .85rem; padding: .4rem .7rem; border: 1px solid var(--border); border-radius: 8px; }
.act-tools select { font-size: .82rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; }
.act-count { font-size: .8rem; color: var(--text-2); }
.act-table-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.act-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.act-table thead th { position: sticky; top: 0; background: #f8fafc; text-align: left; padding: .5rem .75rem; color: var(--text-2); font-weight: 600; border-bottom: 1px solid var(--border); z-index: 1; }
.act-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--border-lt); vertical-align: middle; }
.act-table tr:hover td { background: #fafbff; }
.act-col-btn { width: 1%; white-space: nowrap; }
.act-sub { color: var(--text-3); font-size: .74rem; }
.act-warn { color: #b45309; font-size: .74rem; }
.btn-open-active { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; background: #00815d; color: #fff !important; font-weight: 600; font-size: .86rem;
  padding: .5rem 1rem; border-radius: 8px; text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.btn-open-active:hover { background: #006b4d; }
.btn-open-active:focus-visible { outline: 3px solid #86efac; outline-offset: 2px; }
.btn-get-link { white-space: nowrap; font-size: .8rem; padding: .4rem .8rem; }

/* ── Administration → API Sage Active ───────────────────────────────────── */
.sapi-wrap { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 20px; }
.sapi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 18px; box-shadow: var(--sh); }
.sapi-card h3 { margin: 0 0 8px; font-size: .95rem; color: var(--text); }
.sapi-help { font-size: .78rem; color: var(--text-2); margin: 6px 0 10px; }
.sapi-muted { color: var(--text-3); font-weight: 400; font-size: .82rem; }
.sapi-status { font-size: .88rem; padding: 8px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid var(--border-lt); }
.sapi-status.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.sapi-status.ko { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.sapi-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 10px; }
.sapi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 14px; }
.sapi-grid label, .sapi-full { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--text-2); font-weight: 600; }
.sapi-full { margin-top: 10px; }
.sapi-grid input, .sapi-grid select, .sapi-full input { font: inherit; font-weight: 400; font-size: .85rem; padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.sapi-table-wrap { max-height: 60vh; overflow: auto; border: 1px solid var(--border-lt); border-radius: 8px; }
.sapi-actions button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.sapi-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 16px; box-shadow: var(--sh); }
.sapi-head-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sapi-title { font-weight: 700; font-size: .95rem; color: var(--text); }
.sapi-meta { font-size: .8rem; color: var(--text-2); margin-top: 2px; }
.sapi-pill { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; font-size: .78rem; font-weight: 700; padding: .3rem .7rem; border-radius: 999px; background: #f1f5f9; color: #475569; }
.sapi-pill.ok { background: #dcfce7; color: #166534; }
.sapi-pill.ko { background: #fee2e2; color: #991b1b; }
.sapi-head .sapi-actions { margin-top: 0; }
.sapi-danger { color: #b91c1c; border-color: #fecaca; }
.sapi-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.sapi-k-date { font-size: 18px; padding-top: 6px; }
.sapi-orgs-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sapi-orgs-head h3 { margin: 0; }
.sapi-orgs-head .act-tools { flex: 1; justify-content: flex-end; }
.sapi-orgs-head .act-tools input { max-width: 380px; }
.sapi-orgs .sapi-table-wrap { max-height: calc(100vh - 420px); min-height: 240px; }
.sapi-match { display: inline-block; margin-left: .35rem; font-size: .68rem; padding: .05rem .4rem; border-radius: 999px; background: #eef2ff; color: #3730a3; vertical-align: middle; }
.sapi-match.nom { background: #fef3c7; color: #92400e; }
.sapi-badge { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; background: #f1f5f9; color: #334155; }
.sapi-badge.ready { background: #dcfce7; color: #166534; }
.sapi-id { display: block; white-space: nowrap; font-family: ui-monospace, monospace; font-size: .68rem; color: var(--text-3); margin-top: 2px; }
.sapi-copy { border: 0; background: none; cursor: pointer; color: #4f46e5; font-size: .7rem; padding: 0 .2rem; }
.sapi-keys summary { cursor: pointer; display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: .92rem; color: var(--text); list-style: none; }
.sapi-keys summary::-webkit-details-marker { display: none; }
.sapi-keys summary::before { content: '▸'; margin-right: .4rem; color: var(--text-3); }
.sapi-keys[open] summary::before { content: '▾'; }
.sapi-keys summary > span:first-child { flex: 1; }
.sapi-keys[open] summary { margin-bottom: 8px; }
.btn-open-active.sm { padding: .35rem .75rem; font-size: .8rem; }

/* Onglet API Sage Active : sous-onglets + tableau façon « Gestion des dossiers » */
#tab-sage-api.active { display: flex; flex-direction: column; min-height: 0; }
.sapi-subtabs { display: flex; gap: .4rem; margin-bottom: .7rem; flex-shrink: 0; }
.sapi-subtab { display: inline-flex; align-items: center; gap: .45rem; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: .85rem; font-weight: 600; padding: .45rem .9rem; border-radius: 999px; cursor: pointer; }
.sapi-subtab:hover { border-color: var(--primary-mid); }
.sapi-subtab.active { background: var(--primary-lt); border-color: var(--primary-mid); color: var(--primary-dk); }
.sapi-subtab .sapi-pill { padding: .1rem .5rem; font-size: .7rem; }
.sapi-sub { flex: 1; min-height: 0; }
#sapi-sub-orgs .gd-layout { height: calc(100vh - 230px); }
.sapi-table td { vertical-align: middle; }
.sapi-table td.sapi-right { text-align: right; overflow: visible; }
.sapi-table .sapi-id { display: inline; margin: 0 0 0 .35rem; }
.sapi-list { margin: 0; padding-left: 1.1rem; line-height: 1.6; }
#sapi-sub-orgs .gd-left { width: 250px; }
