@import url('https://fonts.googleapis.com/css2?family=Livvic:wght@300;400;500;600;700&display=swap');

:root {
  --enaos-primary: #1A298C;
  --enaos-primary-hover: #17257F;
  --enaos-primary-foreground: #FFFFFF;
  --enaos-secondary: #DFE3FF;
  --enaos-background: #FFF8ED;
  --enaos-foreground: #20243A;
  --enaos-muted-foreground: #73778C;
  --enaos-muted-foreground-2: #9CA0B3;
  --enaos-card: #FFFFFF;
  --enaos-border: #D4D8E3;
  --enaos-border-50: rgba(212, 216, 227, .5);
  --enaos-destructive: #E74C3C;
  --enaos-success: #2E8F5D;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(26, 41, 140, .05);
  --shadow-md: 0 4px 6px -1px rgba(26, 41, 140, .08), 0 2px 4px -2px rgba(26, 41, 140, .05);
  --shadow-lg: 0 10px 15px -3px rgba(26, 41, 140, .10), 0 4px 6px -4px rgba(26, 41, 140, .05);
  --shadow-cta: 0 4px 14px 0 rgba(26, 41, 140, .2);
}

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

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }

body {
  font-family: 'Livvic', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--enaos-foreground);
  background: var(--enaos-background);
  min-height: 100vh;
}

a { color: var(--enaos-primary); text-decoration: none; }
a:hover { color: var(--enaos-primary-hover); }
input, select, textarea, button { font-family: inherit; }
input[type="checkbox"] { accent-color: var(--enaos-primary); }

/* ── App shell : rail + topbar ── */
.app-shell { min-height: 100vh; display: flex; }

.rail {
  width: 252px; flex: 0 0 252px; min-width: 0; overflow: hidden;
  background: var(--enaos-card);
  border-right: 1px solid var(--enaos-border-50);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .18s ease, flex-basis .18s ease;
}
.rail-head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--enaos-border-50);
}
.rail-brand { min-width: 0; overflow: hidden; flex: 1; }
.rail-brand-full { font-size: 22px; font-weight: 700; color: var(--enaos-primary); letter-spacing: -.01em; line-height: 1.1; white-space: nowrap; }
.rail-brand-full small { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--enaos-muted-foreground); margin-top: 4px; }
.rail-brand-mini { display: none; font-size: 20px; font-weight: 700; color: var(--enaos-primary); letter-spacing: -.01em; }

.rail-toggle {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: var(--radius-full);
  border: 1px solid var(--enaos-border); background: #fff; color: var(--enaos-primary);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.rail-toggle:hover { border-color: var(--enaos-primary); background: var(--enaos-secondary); }
.rail-toggle svg { transition: transform .18s ease; }

.rail-nav { padding: 18px 12px; display: flex; flex-direction: column; gap: 22px; overflow-y: auto; overflow-x: hidden; }
.rail-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--enaos-muted-foreground-2); padding: 0 10px 8px; white-space: nowrap;
}
.rail-group-label .label-mini { display: none; flex-direction: column; align-items: center; gap: 6px; font-size: 9px; letter-spacing: .08em; line-height: 1; }
.rail-group-label .mini-rule { width: 26px; height: 1px; background: var(--enaos-border); }
.rail-group { display: flex; flex-direction: column; gap: 2px; }

.rail-link {
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-full);
  font-size: 13.5px; font-weight: 500; color: var(--enaos-muted-foreground);
  white-space: nowrap; transition: background .18s ease, color .18s ease;
}
.rail-link:hover { background: rgba(223, 227, 255, .5); color: var(--enaos-primary); }
.rail-link.active { background: var(--enaos-secondary); color: var(--enaos-primary); font-weight: 600; }
.rail-bubble {
  position: relative; flex: 0 0 auto; width: 30px; height: 30px; border-radius: var(--radius-full);
  background: rgba(26, 41, 140, .08);
  display: inline-flex; align-items: center; justify-content: center;
  transition: width .18s ease, height .18s ease, background .18s ease;
}
.rail-link.active .rail-bubble { background: rgba(26, 41, 140, .12); }
.rail-bubble img { width: 17px; height: 17px; object-fit: contain; display: block; transition: width .18s ease, height .18s ease; }
.rail-link-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rail-dot {
  display: none;
  position: absolute; top: -1px; right: -1px; width: 8px; height: 8px;
  border-radius: var(--radius-full); background: var(--enaos-destructive); box-shadow: 0 0 0 2px #fff;
}
.rail-badge {
  flex: 0 0 auto; font-size: 11px; font-weight: 700; color: #B23A2B;
  background: rgba(231, 76, 60, .12); padding: 1px 8px; border-radius: var(--radius-full);
}
.rail-foot { margin-top: auto; padding: 16px; border-top: 1px solid var(--enaos-border-50); }
.rail-foot-text { font-size: 11.5px; color: var(--enaos-muted-foreground-2); font-weight: 300; line-height: 1.6; }
.rail-foot-text .env-ok { color: var(--enaos-success); font-weight: 600; }
.rail-foot-mini { display: none; justify-content: center; }
.rail-foot-mini .env-dot { width: 9px; height: 9px; border-radius: var(--radius-full); background: var(--enaos-success); }

/* ── Rail collapsed (icons only) ── */
html.rail-collapsed .rail { width: 72px; flex-basis: 72px; }
html.rail-collapsed .rail-brand-full { display: none; }
html.rail-collapsed .rail-brand-mini { display: block; }
html.rail-collapsed .rail-head { justify-content: center; }
html.rail-collapsed .rail-toggle svg { transform: rotate(180deg); }
html.rail-collapsed .rail-group-label .label-full { display: none; }
html.rail-collapsed .rail-group-label .label-mini { display: flex; }
html.rail-collapsed .rail-group-label { display: flex; justify-content: center; padding: 0 4px 8px; }
html.rail-collapsed .rail-link { justify-content: center; padding: 9px 4px; }
html.rail-collapsed .rail-bubble { width: 38px; height: 38px; }
html.rail-collapsed .rail-bubble img { width: 21px; height: 21px; }
html.rail-collapsed .rail-link-label,
html.rail-collapsed .rail-badge { display: none; }
html.rail-collapsed .rail-dot { display: block; }
html.rail-collapsed .rail-foot-full { display: none; }
html.rail-collapsed .rail-foot-mini { display: flex; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: 64px;
  display: flex; align-items: center; gap: 16px; padding: 0 32px;
  background: rgba(255, 248, 237, .95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--enaos-border-50);
}
.topbar-title { font-size: 17px; font-weight: 700; color: var(--enaos-primary); letter-spacing: -.01em; line-height: 1.2; }
.user-pill {
  display: flex; align-items: center; gap: 10px; padding: 5px 6px 5px 14px;
  background: #fff; border: 1px solid var(--enaos-border-50); border-radius: var(--radius-full); box-shadow: var(--shadow-sm);
}
.user-pill .user-email {
  font-size: 12.5px; color: var(--enaos-muted-foreground); font-weight: 500;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-pill .user-avatar {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  background: var(--enaos-secondary); color: var(--enaos-primary);
  font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

.main { flex: 1; padding: 26px 32px 56px; max-width: 1420px; width: 100%; }

/* ── Flash ── */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
  animation: fadeUp .3s ease-out both;
}
.flash.notice { background: rgba(46, 143, 93, .1); color: #1F6B44; border: 1px solid rgba(46, 143, 93, .25); }
.flash.alert  { background: rgba(231, 76, 60, .1); color: #B23A2B; border: 1px solid rgba(231, 76, 60, .28); }
.flash.alert ul { margin: 6px 0 0; padding-left: 18px; }

.page-actions { margin-bottom: 20px; }

/* ── Search bar ── */
.search-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.search-bar input[type="text"] {
  padding: 9px 14px; border: 1px solid var(--enaos-border); border-radius: var(--radius-full);
  font-size: 13px; background: #fff; color: var(--enaos-foreground); outline: none; transition: border-color .15s;
}
.search-bar input[type="text"]:focus { border-color: var(--enaos-primary); }
.search-bar input[name="search"] { width: 300px; }
.search-bar input[name="amount"] { width: 130px; }

.btn {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.btn-primary   { background: var(--enaos-primary); color: #fff; box-shadow: var(--shadow-cta); }
.btn-primary:hover { background: var(--enaos-primary-hover); color: #fff; }
.btn-secondary {
  background: transparent; color: var(--enaos-muted-foreground);
  border: 1px solid var(--enaos-border);
}
.btn-secondary:hover { border-color: var(--enaos-primary); color: var(--enaos-primary); }
.btn-warning {
  background: #fff; color: var(--enaos-primary); border: 1px solid #C7CCE8;
  font-size: 11.5px; padding: 4px 12px;
}
.btn-warning:hover { background: var(--enaos-primary); color: #fff; border-color: var(--enaos-primary); }
.btn-lg { padding: 11px 26px; font-size: 14px; }
.btn-danger { display: inline-block; padding: 9px 20px; border: 0; border-radius: var(--radius-full); background: var(--enaos-destructive); color: #fff; font-weight: 600; cursor: pointer; }
.btn-danger:hover { background: #C0392B; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--enaos-border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--enaos-muted-foreground);
  white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .18s ease, border-color .18s ease; display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--enaos-primary); }
.tab.active { color: var(--enaos-primary); border-bottom-color: var(--enaos-primary); font-weight: 600; }

.tab-count {
  background: rgba(212, 216, 227, .5); color: var(--enaos-muted-foreground);
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-full);
}
.tab.active .tab-count { background: var(--enaos-secondary); color: var(--enaos-primary); }

/* ── Table ── */
.table-wrapper {
  background: var(--enaos-card);
  border: 1px solid var(--enaos-border-50);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}
.table-wrapper .table-scroll { max-height: 640px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: #F7F5FA; text-align: left; }
th {
  position: sticky; top: 0; z-index: 2; background: #F7F5FA;
  padding: 10px 14px; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--enaos-muted-foreground);
  border-bottom: 1px solid var(--enaos-border-50); white-space: nowrap;
}
td { padding: 9px 14px; border-bottom: 1px solid rgba(212, 216, 227, .35); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(223, 227, 255, .28); }

.col-id   { width: 72px; color: var(--enaos-muted-foreground-2); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.col-date { width: 150px; color: var(--enaos-muted-foreground); font-size: 12px; white-space: nowrap; }

.error-text {
  color: #C0392B; font-size: 12px; max-width: 260px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; display: block; cursor: default;
}

/* ── Empty state ── */
.empty-state { padding: 56px 24px; text-align: center; }
.empty-state .empty-icon {
  width: 56px; height: 56px; border-radius: var(--radius-full); background: var(--enaos-secondary);
  margin: 0 auto 16px; display: flex; align-items: center; justify-content: center;
  color: var(--enaos-primary); font-size: 20px; font-weight: 700;
}
.empty-state h4 { font-size: 15px; margin-bottom: 6px; }
.empty-state p { max-width: 340px; margin: 0 auto 18px; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-received  { background: rgba(26, 41, 140, .1); color: var(--enaos-primary); }
.badge-pending   { background: #FBF0D9; color: #92400E; }
.badge-errored   { background: rgba(231, 76, 60, .12); color: #B23A2B; }
.badge-processed { background: rgba(46, 143, 93, .12); color: #1F6B44; }

.badge-type {
  background: #F4F2FA; color: var(--enaos-foreground); font-size: 11.5px; font-weight: 500;
  padding: 3px 8px; border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Source — couleurs par marque (charte respective), volontairement hors palette Enaos. */
.badge-source {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600; white-space: nowrap; margin: 1px 3px 1px 0;
}
/* !important pour que la couleur de texte de marque l'emporte sur les règles
   contextuelles d'ancre (.detail-grid dd a, tableaux, arbre…) — sinon le texte
   des badges-liens repasse en bleu et devient illisible sur fond coloré. */
.badge-enaos   { background: #1e63d0; color: #ffffff !important; }
.badge-fm      { background: #7fd0f2; color: #0b3a54 !important; }
.badge-legacio { background: #f5c518; color: #4a3600 !important; }
.badge-hubspot { background: #1c1c1c; color: #ffffff !important; }
.badge-odoo    { background: #714b67; color: #ffffff !important; }
.badge-airtable-legacio { background: #f82b60; color: #ffffff !important; }
.badge-airtable-soutien { background: #2d7ff9; color: #ffffff !important; }
.badge-notion  { background: #e9e5de; color: #37352f !important; box-shadow: inset 0 0 0 1px #d3cec4; }
a.badge-link { text-decoration: none; cursor: pointer; }
a.badge-link:hover { filter: brightness(0.92); text-decoration: none; }

/* ── Payload viewer ── */
details summary { cursor: pointer; font-size: 12px; color: var(--enaos-primary); user-select: none; padding: 2px 0; }
details summary:hover { text-decoration: underline; }
details pre {
  margin-top: 8px; background: #F7F5FA; border: 1px solid var(--enaos-border-50); border-radius: var(--radius-md);
  padding: 10px; font-size: 11px; white-space: pre-wrap; word-break: break-word;
  max-width: 380px; max-height: 300px; overflow: auto; color: var(--enaos-foreground);
}

/* ── Forms ── */
.form-card {
  background: var(--enaos-card); border: 1px solid var(--enaos-border-50); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 30px 32px; max-width: 760px;
}
.manual-event-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.manual-event-header h2 { font-size: 17px; font-weight: 600; color: var(--enaos-foreground); }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: var(--enaos-foreground); margin-bottom: 6px; }
.label-hint { font-weight: 300; color: var(--enaos-muted-foreground-2); font-size: 12px; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--enaos-border); border-radius: var(--radius-md);
  font-size: 13px; background: #fff; color: var(--enaos-foreground); outline: none;
  transition: border-color .15s; box-sizing: border-box;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--enaos-primary); }
.form-textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; min-height: 220px; }

.form-actions { margin-top: 26px; }

.pagination { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--enaos-muted-foreground); font-weight: 300; }

.form-section-title { font-size: 13.5px; font-weight: 600; color: var(--enaos-foreground); margin: 26px 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--enaos-border-50); }
.form-hint { font-size: 12px; color: var(--enaos-muted-foreground); font-weight: 300; margin-bottom: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.checkbox-label {
  display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px;
  background: #FBFAFE; border: 1px solid var(--enaos-border-50); border-radius: var(--radius-full);
  padding: 8px 16px; transition: border-color .15s;
}
.checkbox-label:hover { border-color: var(--enaos-primary); }
.checkbox-label input[type="checkbox"] { accent-color: var(--enaos-primary); }
.checkbox-text { color: var(--enaos-foreground); font-weight: 500; }

.required { color: var(--enaos-destructive); }

/* ── Partners explorer ── */
.page-title { margin: 0 0 16px; font-size: 22px; font-weight: 700; color: var(--enaos-primary); letter-spacing: -.01em; }
.section-title { font-size: 14px; font-weight: 700; color: var(--enaos-primary); margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--enaos-secondary); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.section-head .section-title { flex: 1; }
.section-head .btn { margin-bottom: 12px; }
.metabase-embed { display: block; width: 100%; height: 1100px; border: 1px solid var(--enaos-border); border-radius: 12px; background: #fff; }
.filters { flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select {
  padding: 8px 12px; border: 1px solid var(--enaos-border); border-radius: var(--radius-full);
  font-size: 12.5px; background: #fff; color: var(--enaos-foreground); outline: none;
}
.filters .checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--enaos-foreground); font-weight: 500; }
.muted { color: var(--enaos-muted-foreground); font-size: 12px; white-space: nowrap; }
.breadcrumb { margin: 0 0 16px; font-size: 13px; color: var(--enaos-muted-foreground); }
.breadcrumb a { color: var(--enaos-primary); }
.breadcrumb .sep { margin: 0 7px; color: #C2C5D4; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── Fiche partenaire : en-tête ── */
.eyebrow {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--enaos-muted-foreground-2);
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { color: var(--enaos-muted-foreground-2); font-weight: 400; }
.muted-text { color: var(--enaos-muted-foreground); font-size: 12.5px; line-height: 1.55; }
.badge-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 600; background: #F1EFF6; color: var(--enaos-foreground);
}
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: var(--radius-full); background: currentColor; }
.status-on      { background: rgba(46, 143, 93, .12); color: #1F6B44; }
.status-off     { background: rgba(231, 76, 60, .1); color: #B23A2B; }
.status-unknown { background: #F1EFF6; color: var(--enaos-muted-foreground); }

.fiche-hero {
  background: var(--enaos-card); border: 1px solid var(--enaos-border-50); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden;
}
.fiche-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 24px 18px; }
.fiche-hero-id { min-width: 0; flex: 1 1 280px; }
.fiche-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fiche-hero .page-title { margin: 0; font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }
.fiche-subtitle { margin-top: 4px; color: var(--enaos-muted-foreground); font-size: 13.5px; }
.fiche-open-in {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 12px 24px; background: #FBFAFE; border-top: 1px solid var(--enaos-border-50);
}
.fiche-open-in .badge-source { padding: 5px 13px; font-size: 12.5px; }

.dup-alert {
  display: block; margin-bottom: 16px; padding: 11px 16px; border-radius: var(--radius-lg);
  background: #FBF0D9; border: 1px solid #F3DBA0; color: #92400E !important; font-size: 13px;
}
.dup-alert:hover { border-color: #E3B964; }

/* ── Fiche : chiffres clés ── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 18px;
  background: var(--enaos-card); border: 1px solid var(--enaos-border-50); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); color: var(--enaos-foreground);
}
a.stat-tile { transition: border-color .18s ease, box-shadow .18s ease; }
a.stat-tile:hover { border-color: var(--enaos-primary); box-shadow: var(--shadow-md); color: var(--enaos-foreground); }
.stat-label { font-size: 12px; color: var(--enaos-muted-foreground); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--enaos-primary); line-height: 1.1; }

/* ── Fiche : cartes ── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.card {
  background: var(--enaos-card); border: 1px solid var(--enaos-border-50); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 18px 20px; min-width: 0;
}
.card-title { font-size: 13.5px; font-weight: 700; color: var(--enaos-primary); margin-bottom: 10px; }
.kv-list { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 0 18px; }
.kv-list dt, .kv-list dd { padding: 7px 0; border-bottom: 1px solid rgba(212, 216, 227, .3); min-width: 0; }
.kv-list dt { color: var(--enaos-muted-foreground); font-size: 12px; font-weight: 500; }
.kv-list dt.mono { font-size: 11.5px; }
.kv-list dd { margin: 0; font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }
.kv-list > dt:last-of-type, .kv-list > dd:last-of-type { border-bottom: 0; }
/* Carte large (ex. groupement, seule sur sa ligne) : identifiants sur deux colonnes de paires. */
.card { container-type: inline-size; }
@container (min-width: 700px) {
  .kv-ids { grid-template-columns: minmax(110px, max-content) 1fr minmax(110px, max-content) 1fr; }
  /* avant-dernière paire, si elle ouvre la dernière ligne */
  .kv-ids > dt:nth-last-of-type(2):nth-of-type(odd), .kv-ids > dd:nth-last-of-type(2):nth-of-type(odd) { border-bottom: 0; }
}
.uuid-row { margin-top: 10px; padding: 10px 12px; background: #F7F5FA; border-radius: var(--radius-md); display: flex; flex-direction: column; gap: 3px; }
.uuid-row code { color: var(--enaos-muted-foreground); overflow-wrap: anywhere; }

.section-title .count, .fold-summary .count {
  margin-left: 8px; font-size: 12px; font-weight: 500; color: var(--enaos-muted-foreground);
}
#enfants, #fusion { scroll-margin-top: 80px; }
.empty-note { color: var(--enaos-muted-foreground); font-size: 13px; padding: 4px 0; }

/* ── Fiche : enfants (EPF d'un groupement, agences d'une EPF) ── */
.child-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; align-items: start; }
.child-grid-compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.child-card {
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
  background: var(--enaos-card); border: 1px solid var(--enaos-border-50); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 14px 16px;
}
.child-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.child-name { font-weight: 600; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.child-meta { color: var(--enaos-muted-foreground); font-size: 12.5px; margin-top: -4px; }
.child-ids { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--enaos-muted-foreground); font-size: 11.5px; }
.child-sub { border-top: 1px solid var(--enaos-border-50); padding-top: 10px; margin-top: 2px; }
.mini-list { list-style: none; margin: 6px 0 0; }
.mini-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 5px 0; font-size: 13px; }
.mini-list li + li { border-top: 1px solid rgba(212, 216, 227, .3); }
.mini-more summary { margin-top: 4px; font-size: 12.5px; }

/* ── Fiche : section repliable (fusion) ── */
.fold { margin-top: 28px; }
.fold-summary {
  list-style: none; display: flex; align-items: baseline; flex-wrap: wrap;
  font-size: 14px !important; font-weight: 700; color: var(--enaos-primary) !important;
  padding: 0 0 8px; margin-bottom: 12px; border-bottom: 2px solid var(--enaos-secondary);
}
.fold-summary::-webkit-details-marker { display: none; }
.fold-summary::before { content: "▸"; margin-right: 8px; transition: transform .15s ease; display: inline-block; }
.fold[open] > .fold-summary::before { transform: rotate(90deg); }
.fold-summary:hover { text-decoration: none !important; }

/* ── Partners : fusion de doublons ── */
.merge-box { margin: 24px 0 0; padding: 20px 22px; border: 1px solid var(--enaos-border-50); border-radius: var(--radius-lg); background: #FBFAFE; box-shadow: var(--shadow-sm); min-width: 0; }
.fold .merge-box { margin: 0; }
.merge-box h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; color: var(--enaos-primary); }
.dup-list-title { margin-top: 14px; font-size: 13px; }
.dup-list { list-style: none; margin: 4px 0 16px; padding: 0; }
.dup-list li { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 0; border-bottom: 1px solid rgba(212, 216, 227, .35); }
.dup-list li:last-child { border-bottom: 0; }
.merge-link { color: var(--enaos-primary); font-weight: 600; font-size: 12.5px; }
.merge-link:hover { text-decoration: underline; }
.merge-manual { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.merge-manual label { display: flex; flex-direction: column; gap: 5px; flex: 1 1 200px; min-width: 0; font-size: 12.5px; font-weight: 600; }
.merge-manual select { max-width: 100%; padding: 7px 10px; border: 1px solid var(--enaos-border); border-radius: var(--radius-md); font-size: 13px; background: #fff; }
.merge-manual input[type="number"] {
  padding: 7px 12px; border: 1px solid var(--enaos-border); border-radius: var(--radius-md); width: 100%; font-size: 13px; font-weight: 400; outline: none;
}
.merge-manual input[type="number"]:focus { border-color: var(--enaos-primary); }
.merge-manual input[type="submit"] {
  padding: 7px 16px; border: 0; border-radius: var(--radius-full); background: var(--enaos-primary); color: #fff; font-weight: 600; cursor: pointer;
}
.merge-manual input[type="submit"]:hover { background: var(--enaos-primary-hover); }
.merge-compare { width: 100%; border-collapse: collapse; margin: 16px 0; }
.merge-compare th, .merge-compare td { text-align: left; padding: 9px 14px; border-bottom: 1px solid rgba(212, 216, 227, .3); vertical-align: top; font-size: 12.5px; }
.merge-compare thead th { background: #F7F5FA; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--enaos-muted-foreground); }
.merge-compare tbody th { color: var(--enaos-muted-foreground); font-weight: 600; width: 170px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.merge-actions { display: flex; align-items: center; gap: 16px; margin-top: 22px; }

/* ── Partners : boutons de liens externes (index + fiche) ── */
.link-btn {
  display: inline-block; padding: 2px 9px; margin: 1px 0; border: 1px solid #D9DEF5;
  border-radius: var(--radius-full); background: #F3F4FE; color: var(--enaos-primary) !important;
  font-size: 11.5px; white-space: nowrap;
}
.link-btn:hover { background: var(--enaos-primary); color: #fff !important; border-color: var(--enaos-primary); }
.admin-links { white-space: normal; }

/* ── Partners : formulaire d'édition ── */
.edit-form fieldset { border: 1px solid var(--enaos-border-50); border-radius: var(--radius-lg); padding: 6px 20px 18px; margin: 0 0 18px; background: #fff; }
.edit-form legend { padding: 0 8px; font-weight: 700; color: var(--enaos-primary); font-size: 12.5px; }
.edit-form label { display: block; margin: 8px 0; font-size: 13px; color: var(--enaos-foreground); font-weight: 600; }
.edit-form input[type="text"], .edit-form input[type="number"], .edit-form select {
  display: block; width: 100%; max-width: 420px; margin-top: 5px; padding: 9px 12px;
  border: 1px solid var(--enaos-border); border-radius: var(--radius-md); font-size: 13px; font-weight: 400;
  color: var(--enaos-foreground); outline: none;
}
.edit-form input[type="text"]:focus, .edit-form input[type="number"]:focus, .edit-form select:focus { border-color: var(--enaos-primary); }
.edit-form .sources-check { display: flex; flex-wrap: wrap; gap: 14px; }
.edit-form label.checkbox { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; }
.edit-form label.checkbox input { width: auto; margin: 0; accent-color: var(--enaos-primary); }
.edit-actions { display: flex; gap: 14px; align-items: center; margin-top: 8px; }

/* ── Partners : puce de niveau ── */
.level-chip { display: inline-block; padding: 3px 12px; border-radius: var(--radius-full); font-size: 11.5px; font-weight: 600; }
.level-groupements { background: var(--enaos-secondary); color: var(--enaos-primary); }
.level-epfs { background: var(--enaos-secondary); color: var(--enaos-primary); }
.level-agences { background: #D8F5EC; color: #0F766E; }

/* ── Écran de connexion ── */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(to bottom right, var(--enaos-secondary), rgba(223, 227, 255, .55) 55%, var(--enaos-background));
  padding: 40px;
}
.login-card {
  width: 100%; max-width: 432px; background: #fff; border: 1px solid var(--enaos-border-50);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  padding: 40px 40px 32px; text-align: center; animation: fadeUp .5s ease-out both;
}
.login-brand { font-size: 26px; font-weight: 700; color: var(--enaos-primary); letter-spacing: -.01em; }
.login-brand small { display: block; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--enaos-muted-foreground); margin-top: 6px; }
.login-rule { height: 1px; background: rgba(212, 216, 227, .6); margin: 24px 0; }
.login-card h2 { font-size: 18px; font-weight: 600; color: var(--enaos-foreground); margin-bottom: 8px; }
.login-intro { font-size: 14px; color: var(--enaos-muted-foreground); font-weight: 300; line-height: 1.6; margin-bottom: 24px; }
.login-card form { display: block; }
.btn-google { width: 100%; }
.login-warning {
  font-size: 13px; color: #92400E; background: #FBF0D9; border: 1px solid #F3DBA0;
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 16px; text-align: left;
}
.login-help { font-size: 12px; color: var(--enaos-muted-foreground-2); font-weight: 300; margin-top: 24px; line-height: 1.6; }
.login-help code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--enaos-muted-foreground); }

/* ── Petits écrans : rail replié d'office, marges réduites ── */
@media (max-width: 760px) {
  .rail { width: 72px; flex-basis: 72px; }
  .rail-brand-full, .rail-toggle { display: none; }
  .rail-brand-mini { display: block; }
  .rail-head { justify-content: center; }
  .rail-group-label .label-full { display: none; }
  .rail-group-label .label-mini { display: flex; }
  .rail-group-label { display: flex; justify-content: center; padding: 0 4px 8px; }
  .rail-link { justify-content: center; padding: 9px 4px; }
  .rail-link-label, .rail-badge, .rail-foot-full { display: none; }
  .rail-dot { display: block; }
  .rail-foot-mini { display: flex; }

  .topbar { padding: 0 16px; }
  .user-pill .user-email { display: none; }
  .main { padding: 18px 16px 40px; }

  .fiche-hero-top { padding: 18px 16px 14px; }
  .fiche-open-in { padding: 12px 16px; }
  .fiche-hero .page-title { font-size: 20px; }
  .card { padding: 16px; }
}
@media (max-width: 420px) {
  .kv-list { grid-template-columns: 1fr; }
  .kv-list dt { padding-bottom: 0; border-bottom: 0; }
  .kv-list dd { padding-top: 2px; }
}

/* ── Utilisateurs ── */
.users-form-card { margin-bottom: 20px; padding: 22px 26px; }
.users-form-card .form-section-title { margin-top: 0; }
.users-add-form { display: flex; gap: 10px; align-items: center; max-width: 520px; }
.users-add-form .form-input { flex: 1; }
.users-actions { text-align: right; }
.users-actions form { display: inline; }
