/* ==========================================================================
   Fidgi ACS — feuille de style unique (pas de chaîne de build).
   Jetons de design en variables CSS, thème clair / sombre automatique.
   La CSP interdit les styles en ligne : toute la présentation passe par des classes.
   ========================================================================== */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eff1f4;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-text: #ffffff;
  --ring: rgba(79, 70, 229, .22);

  --red: #d92d20;     --red-soft: #fef3f2;    --red-border: #fecdca;
  --orange: #e04f16;  --orange-soft: #fff4ed; --orange-border: #f9dbaf;
  --amber: #b54708;   --amber-soft: #fffaeb;  --amber-border: #fedf89;
  --green: #067647;   --green-soft: #ecfdf3;  --green-border: #abefc6;
  --blue: #175cd3;    --blue-soft: #eff8ff;   --blue-border: #b2ddff;
  --sky: #026aa2;     --sky-soft: #f0f9ff;    --sky-border: #b9e6fe;
  --violet: #6927da;  --violet-soft: #f5f3ff; --violet-border: #d9d6fe;
  --gray: #475467;    --gray-soft: #f2f4f7;   --gray-border: #e4e7ec;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -4px rgba(16, 24, 40, .14), 0 4px 8px -2px rgba(16, 24, 40, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar-w: 256px;

  /* Données : palette catégorielle (ordre fixe), rampe ordinale (avancement), grille et axes discrets */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --ord-1: #86b6ef; --ord-2: #5598e7; --ord-3: #256abf; --ord-4: #104281;
  --chart-grid: #eaecf0; --chart-axis: #d0d5dd; --spark: #98a2b3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111d;
    --surface: #161b26;
    --surface-2: #1b2130;
    --surface-3: #222938;
    --border: #2a3243;
    --border-strong: #3a4458;
    --text: #f5f5f6;
    --text-2: #cecfd2;
    --muted: #94969c;
    --primary: #7c7cf8;
    --primary-hover: #9595fa;
    --primary-soft: #23264a;
    --primary-text: #0c111d;
    --ring: rgba(124, 124, 248, .3);

    --red: #f97066;     --red-soft: #2d1515;    --red-border: #5c2020;
    --orange: #fb9a6b;  --orange-soft: #2c1a10; --orange-border: #5a3018;
    --amber: #fdb022;   --amber-soft: #2a2110;  --amber-border: #54400f;
    --green: #47cd89;   --green-soft: #0f2a1d;  --green-border: #1c5236;
    --blue: #84caff;    --blue-soft: #102238;   --blue-border: #1d4570;
    --sky: #7cd4fd;     --sky-soft: #0f2532;    --sky-border: #1a4a62;
    --violet: #bdb4fe;  --violet-soft: #221b3d; --violet-border: #40327a;
    --gray: #cecfd2;    --gray-soft: #222938;   --gray-border: #333b4d;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, .55);

    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --ord-1: #184f95; --ord-2: #256abf; --ord-3: #3987e5; --ord-4: #86b6ef;
    --chart-grid: #222938; --chart-axis: #3a4458; --spark: #667085;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.55 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; font-weight: 650; }
h2 { font-size: 1rem; margin: 0; font-weight: 600; }
h3 { font-size: .9rem; margin: 0 0 .4rem; font-weight: 600; }
p { margin: 0 0 .6rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Structure : barre latérale + contenu pleine largeur ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.05rem; padding: 4px 8px 18px; }
.brand:hover { color: var(--text); }
.brand b { font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #a855f7);
  color: #fff; box-shadow: 0 4px 12px -2px rgba(99, 102, 241, .45);
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active .icon { stroke: var(--primary); }

.sidebar-footer { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: var(--radius-sm); color: var(--text); }
.me:hover { background: var(--surface-3); color: var(--text); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.me-text b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.backdrop { display: none; }
.content { width: 100%; padding: 28px 36px 56px; }
.mobilebar { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .backdrop { display: block; }
  .backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 30; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobilebar .brand { padding: 0; }
  .content { padding: 20px 16px 48px; }
}

/* ---------- En-tête de page ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header .subtitle { color: var(--muted); margin: 4px 0 0; }
.breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Barre fixe : compteurs, recherche et filtres restent visibles au défilement ---------- */
/* Fond étendu aux bords du contenu (marges négatives = rembourrage de .content) : la liste passe dessous proprement. */
.sticky-bar {
  position: sticky; top: 0; z-index: 25;
  display: flow-root; /* les marges des cartes restent dans la barre : la liste ne transparaît pas dessous */
  margin: -12px -36px 0; padding: 12px 36px 0;
  background: var(--bg);
  transition: box-shadow .15s ease;
}
.sticky-sentinel { height: 1px; margin-bottom: -1px; }
/* Liens internes (#section) : le défilement s'arrête sous la barre fixe (hauteur mesurée par app.js, 0 sans barre). */
[id] { scroll-margin-top: calc(var(--sticky-offset, 0px) + 16px); }
.section-nav { margin-top: -8px; }
@media (min-width: 961px) and (min-height: 621px) {
  .sticky-bar.is-stuck { box-shadow: 0 1px 0 var(--border), 0 12px 20px -16px rgba(16, 24, 40, .45); }

  /* Version compacte une fois fixée : plus de place pour la liste. */
  .sticky-bar.is-stuck .page-header { margin-bottom: 12px; }
  .sticky-bar.is-stuck .page-header { align-items: center; }
  .sticky-bar.is-stuck .page-header > div:first-child { flex: 1 1 0; min-width: 0; }
  .sticky-bar.is-stuck .page-header h1 { font-size: 1.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sticky-bar.is-stuck .page-header .breadcrumb { margin-bottom: 2px; }
  .sticky-bar.is-stuck .page-header .app-logo { width: 32px; height: 32px; border-radius: 8px; font-size: .8rem; }
  .sticky-bar.is-stuck .page-header .avatar.lg { width: 30px; height: 30px; font-size: .72rem; }
  /* Détail d'un incident : titre sur une ligne, frise d'avancement resserrée. */
  .sticky-bar.is-stuck .incident-head { margin-bottom: 10px; align-items: center; }
  .sticky-bar.is-stuck .incident-head > div:first-child { flex: 1 1 0; min-width: 0; }
  .sticky-bar.is-stuck .incident-head .breadcrumb { margin-bottom: 2px; }
  .sticky-bar.is-stuck .incident-head h1 { font-size: 1.15rem; margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sticky-bar.is-stuck .merged-alert { margin-bottom: 10px; padding-top: 6px; padding-bottom: 6px; }
  .sticky-bar.is-stuck .stepper { padding: 8px 16px; margin-bottom: 12px; }
  .sticky-bar.is-stuck .step .bullet { width: 20px; height: 20px; }
  /* Compteurs en pastilles : icône, valeur et libellé sur une ligne, tous sur une seule rangée. */
  .sticky-bar.is-stuck .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
  .sticky-bar.is-stuck .kpi { padding: 6px 10px; gap: 8px; }
  .sticky-bar.is-stuck .kpi:hover { transform: none; }
  .sticky-bar.is-stuck .kpi-icon { width: 26px; height: 26px; border-radius: 7px; }
  .sticky-bar.is-stuck .kpi-icon .icon.lg { width: 16px; height: 16px; }
  .sticky-bar.is-stuck .kpi > span:last-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sticky-bar.is-stuck .kpi br { display: none; }
  .sticky-bar.is-stuck .kpi-value { font-size: 1.05rem; margin-right: 6px; }
  .sticky-bar.is-stuck .filters { margin-bottom: 12px; padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .sticky-bar.is-stuck .tabs { margin-bottom: 10px; }
  .sticky-bar.is-stuck .tabs a { padding-top: 6px; padding-bottom: 6px; }
  /* Rapports : le formulaire de génération se réduit à une ligne (champs et bouton). */
  .sticky-bar.is-stuck .report-generator { margin-bottom: 12px; }
  .sticky-bar.is-stuck .report-generator .card-header,
  .sticky-bar.is-stuck .report-generator .hint { display: none; }
  .sticky-bar.is-stuck .report-generator .card-body { padding: 10px 14px; }
}
/* Petits écrans : barre normale (fixée, elle occuperait la moitié de l'écran). */
@media (max-width: 960px), (max-height: 620px) {
  .sticky-bar { position: static; margin: 0; padding: 0; background: none; }
}

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-body { padding: 18px 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { display: flex; align-items: center; gap: 8px; }
.card-header h2 .icon { color: var(--muted); }
.card-header .count { background: var(--surface-3); color: var(--muted); border-radius: 99px; padding: 0 8px; font-size: .75rem; font-weight: 600; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { align-self: start; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
/* Colonne latérale collante seulement si elle tient dans la fenêtre (classe « fits » posée par app.js) : sinon son bas
   resterait inaccessible. Placée sous la barre fixe éventuelle. */
.split > aside.fits { position: sticky; top: calc(var(--sticky-offset, 0px) + 20px); }
@media (max-width: 1200px) { .split { grid-template-columns: 1fr; } .split > aside, .split > aside.fits { position: static; } }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 34px; height: 34px; }
  .filters-row select, .filters-row input[type=date] { min-width: 0; flex: 1 1 140px; }
  .filters .input-icon { flex-basis: 100%; }
  .divider-v { display: none; }
  .page-header .header-actions, .page-header .header-actions .btn { width: 100%; }
  .card-header, .card-body, .card-footer { padding-left: 14px; padding-right: 14px; }
}

/* ---------- Formulaires ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--text-2); font-size: .9rem; }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.hint { color: var(--muted); font-weight: 400; font-size: .82rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 11px; min-height: 38px; width: 100%;
  box-shadow: var(--shadow-xs);
  transition: border-color .12s, box-shadow .12s;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; box-shadow: none; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
input[type=file] { padding: 6px; }
input[type=file]::file-selector-button {
  font: inherit; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
  border-radius: 6px; padding: 4px 10px; margin-right: 10px; cursor: pointer;
}
.field-error { color: var(--red); font-weight: 400; font-size: .82rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.input-icon { position: relative; flex: 1 1 320px; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 36px; }

/* ---------- Boutons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .88rem; line-height: 1;
  min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-xs); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: var(--surface-2); color: var(--text); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.btn-primary, button.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover, button.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-text); }
.btn-success { background: var(--green); border-color: var(--green); color: var(--primary-text); }
.btn-success:hover { filter: brightness(1.08); background: var(--green); color: var(--primary-text); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .8rem; }
.btn-link { background: none; border: none; box-shadow: none; color: var(--primary); padding: 0; min-height: 0; font-weight: 500; }
.btn-link:hover { background: none; color: var(--primary-hover); text-decoration: underline; }
.btn-link.danger { color: var(--red); }
.icon-btn { min-height: 34px; width: 34px; padding: 0; border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- Badges, pastilles, avatars ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 600; line-height: 1.5;
  border: 1px solid var(--gray-border); background: var(--gray-soft); color: var(--gray); white-space: nowrap;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-NOUVEAU    { color: var(--violet); background: var(--violet-soft); border-color: var(--violet-border); }
.st-ASSIGNE    { color: var(--sky);    background: var(--sky-soft);    border-color: var(--sky-border); }
.st-EN_COURS   { color: var(--blue);   background: var(--blue-soft);   border-color: var(--blue-border); }
.st-EN_ATTENTE { color: var(--amber);  background: var(--amber-soft);  border-color: var(--amber-border); }
.st-RESOLU     { color: var(--green);  background: var(--green-soft);  border-color: var(--green-border); }
.st-CLOTURE    { color: var(--gray);   background: var(--gray-soft);   border-color: var(--gray-border); }

.prio { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .8rem; white-space: nowrap; }
.prio::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }
.prio-P1 { color: var(--red); }    .prio-P1::before { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.prio-P2 { color: var(--orange); } .prio-P2::before { background: var(--orange); }
.prio-P3 { color: var(--amber); }  .prio-P3::before { background: var(--amber); }
.prio-P4 { color: var(--muted); }  .prio-P4::before { background: var(--border-strong); }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: .75rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.tag.internal { background: var(--violet-soft); color: var(--violet); }
.tag.danger { background: var(--red-soft); color: var(--red); }
.tag.success { background: var(--green-soft); color: var(--green); }
.ref { font-family: var(--mono); font-size: .8rem; color: var(--muted); font-weight: 500; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em; color: #fff;
}
.avatar.sm { width: 24px; height: 24px; font-size: .62rem; }
.avatar.lg { width: 38px; height: 38px; font-size: .85rem; }
.av-0 { background: #6366f1; } .av-1 { background: #0ea5e9; } .av-2 { background: #14b8a6; } .av-3 { background: #f59e0b; }
.av-4 { background: #ec4899; } .av-5 { background: #8b5cf6; } .av-6 { background: #22c55e; } .av-7 { background: #ef4444; }
.person { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Tuiles d'indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s, transform .12s;
}
.kpi:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kpi.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.kpi-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex: none; }
.kpi-value { font-size: 1.55rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-blue   { background: var(--blue-soft);   color: var(--blue); }
.tone-red    { background: var(--red-soft);    color: var(--red); }
.tone-amber  { background: var(--amber-soft);  color: var(--amber); }
.tone-green  { background: var(--green-soft);  color: var(--green); }
.tone-sky    { background: var(--sky-soft);    color: var(--sky); }
.tone-gray   { background: var(--gray-soft);   color: var(--gray); }

/* ---------- Barre de filtres ---------- */
.filters { padding: 14px 16px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters-row select { width: auto; min-width: 200px; }
.filters-row input[type=date] { width: auto; }
.filter-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-group > .label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.chip { position: relative; display: inline-flex; flex-direction: row; cursor: pointer; font-weight: 500; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: .8rem;
  transition: all .12s;
}
.chip:hover span { border-color: var(--primary); }
.chip input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }
.divider-v { width: 1px; align-self: stretch; background: var(--border); margin: 0 6px; }

/* ---------- Tableaux ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  text-align: left; font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr[data-href] { cursor: pointer; }
.table .col-check { width: 44px; padding-right: 0; }
.table .title-cell { min-width: 280px; }
.table .title-cell b { display: block; font-weight: 600; color: var(--text); }
.table .title-cell small { color: var(--muted); }
.table.compact td, .table.compact th { padding: 9px 14px; }
.table tr.inactive td { opacity: .55; }
.table td.cell-actions { text-align: right; white-space: nowrap; }
.table td.cell-actions form { display: inline; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.table-toolbar .result-count { color: var(--muted); font-weight: 500; }
.bulk { display: flex; align-items: center; gap: 8px; }
.bulk select { width: auto; min-width: 200px; min-height: 32px; padding: 4px 10px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }

.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state .icon { width: 40px; height: 40px; stroke-width: 1.4; color: var(--border-strong); margin-bottom: 10px; }
.empty-state b { display: block; color: var(--text); font-size: 1rem; margin-bottom: 4px; }

/* ---------- Notifications (toasts) ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 36px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease-out; font-weight: 500;
}
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: var(--green); }
.toast.error { border-color: var(--red-border); }
.toast.error .icon { color: var(--red); }
.toast.hide { opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
.toast button { margin-left: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.alert.error { background: var(--red-soft); border-color: var(--red-border); color: var(--red); }
.alert.success { background: var(--green-soft); border-color: var(--green-border); color: var(--green); }
.alert.info { background: var(--blue-soft); border-color: var(--blue-border); color: var(--blue); }

/* ---------- Détail d'un incident ---------- */
.incident-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.incident-head h1 { margin: 2px 0 10px; max-width: 980px; }
.meta-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); }

.stepper { display: flex; padding: 16px 20px; margin-bottom: 20px; gap: 0; overflow-x: auto; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 130px; color: var(--muted); font-weight: 500; font-size: .85rem; }
.step:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--border); margin: 0 12px; border-radius: 2px; min-width: 16px; }
.step .bullet { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); flex: none; }
.step.done { color: var(--text-2); }
.step.done .bullet { background: var(--green); border-color: var(--green); color: #fff; }
.step.done:not(:last-child)::after { background: var(--green); }
.step.current { color: var(--primary); font-weight: 650; }
.step.current .bullet { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.step.current .bullet::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.step.paused { color: var(--amber); font-weight: 650; }
.step.paused .bullet { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }

.description { font-size: .95rem; color: var(--text-2); }
.resolution-box { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--green-soft); border: 1px solid var(--green-border); }
.resolution-box h3 { color: var(--green); display: flex; align-items: center; gap: 6px; }

.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.popover { position: relative; }
.popover > summary { list-style: none; }
.popover > summary::-webkit-details-marker { display: none; }
.popover-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(420px, 90vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px;
}
.popover-panel h3 { margin-bottom: 10px; }

.props { display: grid; grid-template-columns: 130px 1fr; gap: 12px 12px; margin: 0; }
.props dt { color: var(--muted); display: flex; align-items: center; gap: 7px; font-size: .85rem; }
.props dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.comments { display: flex; flex-direction: column; gap: 18px; }
.comment { display: flex; gap: 12px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.comment-meta b { font-weight: 600; }
.bubble { padding: 10px 14px; border-radius: 4px var(--radius) var(--radius) var(--radius); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.comment.internal .bubble { background: var(--violet-soft); border-color: var(--violet-border); }
.composer { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-3); gap: 2px; }
.segmented label { flex-direction: row; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 6px; font-size: .82rem; color: var(--muted); font-weight: 600; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline li { position: relative; display: flex; gap: 14px; padding: 0 0 14px; }
.timeline .t-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); flex: none; }
.timeline .t-dot .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.timeline .t-body { flex: 1; min-width: 0; font-size: .88rem; color: var(--text-2); padding-top: 2px; }
.timeline .t-body b { color: var(--text); font-weight: 600; }
.timeline .t-time { color: var(--muted); font-size: .78rem; white-space: nowrap; padding-top: 3px; }
.timeline .t-change { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.timeline .t-old { text-decoration: line-through; color: var(--muted); }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.file-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); flex: none; }
.file-info { flex: 1; min-width: 0; }
.file-info a { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info small { color: var(--muted); }
.upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.upload input[type=file] { flex: 1 1 240px; }

details.collapsible > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::after { content: "›"; font-size: 1.3rem; color: var(--muted); transition: transform .15s; }
details.collapsible[open] > summary::after { transform: rotate(90deg); }
details.collapsible[open] > summary { margin-bottom: 14px; }

/* ---------- Cartes d'applications ---------- */
.app-card { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; color: var(--text); transition: border-color .12s, box-shadow .12s, transform .12s; }
.app-card:hover { color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.app-card-head { display: flex; align-items: center; gap: 12px; }
.app-logo { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; font-weight: 700; color: #fff; flex: none; }
.app-card p { color: var(--muted); margin: 0; font-size: .88rem; }

/* ---------- Connexion ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 56px; color: #fff;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, .16), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(168, 85, 247, .55), transparent 45%),
    linear-gradient(140deg, #312e81 0%, #4f46e5 45%, #7c3aed 100%);
}
.auth-hero .brand { color: #fff; padding: 0; }
.auth-hero .brand-mark { background: rgba(255, 255, 255, .18); box-shadow: none; }
.auth-hero h2 { color: #fff; font-size: 2.1rem; line-height: 1.2; font-weight: 700; max-width: 520px; letter-spacing: -.02em; margin-bottom: 14px; }
.auth-hero p { color: rgba(255, 255, 255, .82); max-width: 480px; font-size: 1rem; }
.pdca { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-width: 560px; }
.pdca div { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2); border-radius: 12px; padding: 12px; backdrop-filter: blur(4px); }
.pdca b { display: block; font-size: 1.3rem; }
.pdca small { color: rgba(255, 255, 255, .8); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 380px; }
.auth-form h1 { margin-bottom: 6px; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- Divers ---------- */
.token { display: block; margin-top: 8px; padding: 10px; background: var(--surface); border: 1px dashed var(--green-border); border-radius: 8px; word-break: break-all; user-select: all; color: var(--text); }
.help-list { margin: 0; padding-left: 18px; color: var(--text-2); }
.help-list li { margin-bottom: 6px; }
.prio-legend { display: flex; flex-direction: column; gap: 10px; }
.prio-legend div { display: flex; flex-direction: column; gap: 2px; }
.error-page { display: grid; place-items: center; min-height: 60vh; text-align: center; }
.error-page .code { font-size: 4rem; font-weight: 800; letter-spacing: -.04em; background: linear-gradient(135deg, var(--primary), #a855f7); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }

/* ---------- SLA ---------- */
.sla-ON_TRACK { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.sla-AT_RISK  { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.sla-BREACHED { color: var(--red);   background: var(--red-soft);   border-color: var(--red-border); }
.sla-PAUSED   { color: var(--gray);  background: var(--gray-soft);  border-color: var(--gray-border); }
.sla-MET      { color: var(--green); background: transparent;       border-color: var(--green-border); }
.sla-MISSED   { color: var(--red);   background: transparent;       border-color: var(--red-border); }
.tag.sla-MET, .tag.sla-MISSED { border: 1px solid; }
.sla-target { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.sla-target:last-of-type { border-bottom: none; }
progress.sla-progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: none; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
progress.sla-progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 99px; }
progress.sla-progress::-webkit-progress-value { border-radius: 99px; background: var(--green); transition: width .3s; }
progress.sla-progress::-moz-progress-bar { border-radius: 99px; background: var(--green); }
progress.sla-AT_RISK::-webkit-progress-value { background: var(--amber); }   progress.sla-AT_RISK::-moz-progress-bar { background: var(--amber); }
progress.sla-BREACHED::-webkit-progress-value, progress.sla-MISSED::-webkit-progress-value { background: var(--red); }
progress.sla-BREACHED::-moz-progress-bar, progress.sla-MISSED::-moz-progress-bar { background: var(--red); }
progress.sla-PAUSED::-webkit-progress-value { background: var(--border-strong); } progress.sla-PAUSED::-moz-progress-bar { background: var(--border-strong); }
.text-danger { color: var(--red); }
.card.spaced, #sla-policy { margin-bottom: 16px; }
.notif-SENT { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.notif-PENDING, .notif-SENDING { color: var(--sky); background: var(--sky-soft); border-color: var(--sky-border); }
.notif-FAILED { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.notif-DEAD { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }
.table td .row { flex-wrap: nowrap; }
.table input[type=number] { max-width: 120px; }
.table input[type=time] { width: auto; }
.tag, .badge, .person, .prio { white-space: nowrap; }
.table td.nowrap { white-space: nowrap; }
.cell-sub { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* ---------- Base de connaissances et doublons ---------- */
.toast.warning { border-color: var(--amber-border); }
.toast.warning .icon { color: var(--amber); }
.clamp-1, .clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; } .clamp-2 { -webkit-line-clamp: 2; } .clamp-3 { -webkit-line-clamp: 3; }
.kb-card h2 { font-size: 1.02rem; }
.kb-DRAFT { color: var(--gray); background: var(--gray-soft); border-color: var(--gray-border); }
.kb-PUBLISHED { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.kb-ARCHIVED { color: var(--muted); background: transparent; }
.solution-card { border-color: var(--green-border); }
.solution-card .card-header { background: var(--green-soft); border-radius: var(--radius) var(--radius) 0 0; }
.solution-card .card-header h2, .solution-card .card-header .icon { color: var(--green); }
.suggest-card { border-color: var(--violet-border); }
.suggest-card .card-header { background: var(--violet-soft); border-radius: var(--radius) var(--radius) 0 0; }
.suggest-card .card-header h2, .suggest-card .card-header .icon { color: var(--violet); }
.warn-card { border-color: var(--amber-border); }
.warn-card .card-header { background: var(--amber-soft); border-radius: var(--radius) var(--radius) 0 0; }
.warn-card .card-header h2, .warn-card .card-header .icon { color: var(--amber); }
.suggestions { list-style: none; margin: 0; padding: 6px 0; }
.suggestions li { display: flex; flex-direction: column; gap: 2px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.suggestions li:last-child { border-bottom: none; }
.kb-linked, .dup-candidate { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.kb-suggestion, .rel-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kb-suggestion:last-child, .rel-row:last-child { border-bottom: none; }
.kb-suggestion a { flex: 1; min-width: 0; }
.label-sm { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.score { font-weight: 700; font-size: .85rem; color: var(--amber); background: var(--amber-soft); border-radius: 6px; padding: 1px 8px; }
.merged-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--blue-soft); color: var(--blue); }
.merged-alert { margin-bottom: 16px; }
.merged-alert a { font-weight: 600; }
.kb-card .row .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.keywords { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }

/* ---------- Problèmes et actions correctives ---------- */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 4px 0 0; }
.section-title .icon { color: var(--amber); }
#suggestions { margin-bottom: 20px; }
.pb-OUVERT { color: var(--violet); background: var(--violet-soft); border-color: var(--violet-border); }
.pb-EN_ANALYSE { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-border); }
.pb-CAUSE_IDENTIFIEE { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.pb-RESOLU { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.pb-CLOTURE { color: var(--gray); background: var(--gray-soft); border-color: var(--gray-border); }
.ac-A_FAIRE { color: var(--gray); background: var(--gray-soft); border-color: var(--gray-border); }
.ac-EN_COURS { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-border); }
.ac-FAITE { color: var(--sky); background: var(--sky-soft); border-color: var(--sky-border); }
.ac-VERIFIEE { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.ap-HAUTE { background: var(--red-soft); color: var(--red); }
.ap-MOYENNE { background: var(--amber-soft); color: var(--amber); }
.ap-BASSE { background: var(--gray-soft); color: var(--gray); }
.ef-PENDING { background: var(--sky-soft); color: var(--sky); }
.ef-EFFECTIVE { background: var(--green-soft); color: var(--green); }
.ef-INEFFECTIVE { background: var(--red-soft); color: var(--red); }
progress.sla-progress.mini { width: 70px; height: 6px; }
.cause-box { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--amber-soft); border: 1px solid var(--amber-border); }
.cause-box h3 { color: var(--amber); display: flex; align-items: center; gap: 6px; }
.edit-block { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.move-buttons { gap: 10px; margin-top: 4px; }
.title-cell .tag { margin-top: 4px; }

/* 5 pourquoi */
.whys { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.why-row { display: flex; gap: 12px; align-items: flex-start; }
.why-rank { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; flex: none; margin-top: 4px; }
.why-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; padding-left: 12px; border-left: 2px dashed var(--border); }
.why-fields textarea { min-height: 52px; }

/* Ishikawa (arête de poisson simplifiée) */
.fishbone { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(140px, 200px); grid-template-rows: auto 14px auto; gap: 10px 14px; margin-top: 12px; }
.fb-cat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; position: relative; }
.fb-cat h4 { margin: 0 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fb-cat ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.fb-cat li { display: flex; gap: 6px; align-items: baseline; }
.fb-cat li.retained { font-weight: 600; color: var(--text); }
.fb-cat li.retained .icon { color: var(--green); }
.fb-tools { margin-left: auto; display: inline-flex; gap: 8px; opacity: 0; transition: opacity .12s; }
.fb-cat li:hover .fb-tools, .fb-tools:focus-within { opacity: 1; }
.fb-cat.top::after, .fb-cat.bottom::before { content: ""; position: absolute; left: 50%; width: 2px; height: 12px; background: var(--border-strong); }
.fb-cat.top::after { bottom: -13px; }
.fb-cat.bottom::before { top: -13px; }
.fb-spine { grid-column: 1 / 4; grid-row: 2; align-self: center; height: 3px; border-radius: 2px; background: var(--border-strong); position: relative; }
.fb-spine::after { content: ""; position: absolute; right: -8px; top: -5px; border-left: 10px solid var(--border-strong); border-top: 6.5px solid transparent; border-bottom: 6.5px solid transparent; }
.fb-head { grid-column: 4; grid-row: 1 / 4; display: grid; place-items: center; text-align: center; padding: 12px; border-radius: var(--radius); background: var(--red-soft); border: 1px solid var(--red-border); color: var(--red); font-weight: 600; font-size: .9rem; }
.fishbone .fb-cat.bottom { grid-row: 3; }
.fb-add { margin-top: 12px; }
.fb-add select { width: auto; }
@media (max-width: 900px) {
  .fishbone { grid-template-columns: 1fr; grid-template-rows: none; }
  .fb-head, .fb-spine, .fishbone .fb-cat.bottom { grid-column: auto; grid-row: auto; }
  .fb-spine, .fb-cat.top::after, .fb-cat.bottom::before { display: none; }
}

/* Onglets */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: var(--surface-3); border-radius: 99px; padding: 0 7px; font-size: .75rem; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 320px; transition: border-color .12s, box-shadow .12s; }
.kanban-col header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.kanban-col header .count { background: var(--surface-3); color: var(--muted); border-radius: 99px; padding: 0 8px; font-size: .75rem; font-weight: 600; }
.kanban-col.drop-ok { border-color: var(--primary); border-style: dashed; }
.kanban-col.drop-over { box-shadow: 0 0 0 4px var(--ring); background: var(--primary-soft); }
.kanban-cards { display: flex; flex-direction: column; gap: 10px; padding: 10px; flex: 1; }
.kanban-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs); }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.dragging { opacity: .5; }
.kanban-card.overdue { border-left: 3px solid var(--red); }
.kanban-card b { font-size: .92rem; }
.kanban-card .card-title-link { color: var(--text); }
.kanban-card .card-title-link:hover { color: var(--primary); }
.kanban-empty { text-align: center; color: var(--muted); font-size: .85rem; margin: 12px 0; }
/* En-têtes de colonnes (statut et nombre d'actions) fixés juste sous la barre fixe, quand les 4 colonnes tiennent
   sans défilement horizontal (--sticky-offset = hauteur de la barre, mesurée par app.js). */
@media (min-width: 1340px) and (min-height: 621px) {
  .kanban { overflow-x: visible; }
  .kanban-col header {
    position: sticky; top: var(--sticky-offset, 0px); z-index: 5;
    background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0;
  }
}

/* Retouches étape 5 */
.score { white-space: nowrap; }
.grid-cards > .suggest-card { display: flex; flex-direction: column; }
.grid-cards > .suggest-card .card-body { flex: 1; }
.action-meta { gap: 8px; margin-top: 6px; }
.move-buttons { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.fb-cat li { position: relative; }
.fb-tools { position: absolute; right: -4px; top: -2px; padding: 0 4px; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow-sm); display: none; }
.fb-cat li:hover .fb-tools, .fb-tools:focus-within { display: inline-flex; opacity: 1; }

/* ---------- Enquête de satisfaction, intégration ---------- */
.survey-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 20% 10%, var(--primary-soft), transparent 50%), var(--bg); }
.survey-card { width: 100%; max-width: 560px; }
.survey-card .brand { padding: 0 0 6px; }
.survey-title { font-weight: 600; margin: 8px 0 0; }
.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; border: 0; padding: 0; margin: 0; }
.rating label { position: relative; cursor: pointer; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); transition: all .12s; text-align: center; }
.rating b { font-size: 1.4rem; }
.rating small { font-size: .7rem; color: var(--muted); line-height: 1.2; }
.rating label:hover span { border-color: var(--primary); }
.rating input:focus-visible + span { box-shadow: 0 0 0 4px var(--ring); }
.rating .r1 input:checked + span, .rating .r2 input:checked + span { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.rating .r3 input:checked + span { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.rating .r4 input:checked + span, .rating .r5 input:checked + span { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.stars { display: flex; align-items: center; gap: 2px; font-size: 1.3rem; color: var(--border-strong); }
.stars .on { color: #f5b301; }
.stars b { font-size: .95rem; color: var(--text); margin-left: 8px; }
.inactive-block { opacity: .6; }
.wh-SUCCEEDED { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.wh-PENDING, .wh-SENDING { color: var(--sky); background: var(--sky-soft); border-color: var(--sky-border); }
.wh-FAILED { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-border); }
.wh-DEAD { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }
#api-keys, #webhooks { margin-bottom: 16px; }
@media (max-width: 520px) { .rating small { display: none; } }
/* Formulaires en ligne : les champs ne prennent pas toute la largeur (sinon passage à la ligne) */
.row > select, .row > input:not([type=checkbox]):not([type=radio]) { width: auto; }
.row > .spacer { flex: 1 1 180px; min-width: 0; }

/* ==========================================================================
   Tableau de bord (étape 7)
   ========================================================================== */
.dash-filters .filters-row select { min-width: 170px; }
.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.tile { position: relative; padding: 16px 18px 12px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-height: 148px; }
.tile-label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 1.85rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin-top: 4px; }
.tile-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: .82rem; }
.tile-delta { font-weight: 600; display: inline-flex; gap: 3px; }
.tile-delta.good { color: var(--green); }
.tile-delta.bad { color: var(--red); }
.tile-delta.neutral { color: var(--text-2); }
.tile-prev, .tile-hint { color: var(--muted); font-size: .8rem; }
.spark { display: block; width: 100%; height: 30px; margin-top: auto; padding-top: 8px; overflow: visible; }
.spark polyline { fill: none; stroke: var(--spark); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin-bottom: 26px; }
.dash-grid > .card { min-width: 0; }
.span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.dashboard .section-title { margin: 4px 0 12px; }
.dashboard > .card.table-card { margin-bottom: 26px; }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: .8rem; font-weight: 400; }
.chart-card .card-body { display: flex; flex-direction: column; gap: 10px; }
.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 200px; }
.chart-empty { color: var(--muted); padding: 28px 20px; text-align: center; font-size: .88rem; }
.data-view summary { cursor: pointer; color: var(--muted); font-size: .8rem; width: max-content; }
.data-view summary:hover { color: var(--text); }
.data-view[open] summary { margin-bottom: 8px; }
.table.compact th, .table.compact td { padding: 8px 14px; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.compact td:first-child { white-space: nowrap; }
.table.compact td.title-cell { white-space: normal; }
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: none; padding: 8px 14px; }
.figures-inline { display: flex; gap: 14px; color: var(--muted); font-size: .84rem; }
.figures-inline b { color: var(--text); font-size: 1rem; }
.figures { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 14px; }
.figures > div { display: flex; flex-direction: column; }
.figures b { font-size: 1.5rem; font-weight: 650; letter-spacing: -.01em; }
.figures span { color: var(--muted); font-size: .8rem; }
.figures .alert-figure b { color: var(--red); }
.line-list { list-style: none; margin: 8px 0 0; padding: 0; }
.line-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); font-size: .86rem; }
.line-list li .clamp-1 { flex: 1; min-width: 0; }

/* Jauges (barres horizontales en SVG : largeur en %, pas de style en ligne) */
.meter-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.meter-list li { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr) auto; align-items: center; gap: 12px; font-size: .86rem; }
.meter-label { display: flex; flex-direction: column; min-width: 0; }
.meter-label > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-label small { color: var(--muted); font-size: .76rem; }
.meter { display: block; overflow: visible; }
.meter-track { fill: var(--surface-3); }
.meter-fill { fill: var(--series-1); }
.meter-value { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.meter-value small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.load { display: grid; grid-template-columns: minmax(80px, 1fr) 10.5em; align-items: center; gap: 12px; }
.load .meter-value { text-align: left; }
.table th.w-load { width: 40%; }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }

/* Barre segmentée (part d'un tout, rampe ordinale) et légende */
.segbar { display: block; border-radius: 6px; overflow: hidden; margin: 4px 0 10px; }
.segbar .seg { stroke: var(--surface); stroke-width: 2; }
.ord-1 { fill: var(--ord-1); background: var(--ord-1); } .ord-2 { fill: var(--ord-2); background: var(--ord-2); }
.ord-3 { fill: var(--ord-3); background: var(--ord-3); } .ord-4 { fill: var(--ord-4); background: var(--ord-4); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: .8rem; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Rapports mensuels */
.report-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.report-form select { width: auto; min-width: 190px; }
.report-generator { margin-bottom: 16px; }
.report-generator .hint { margin: 10px 0 0; }
.report-form label.check { display: inline-flex; gap: 6px; align-items: center; font-size: .86rem; color: var(--text-2); }

@media (max-width: 1180px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-4, .span-6, .span-8 { grid-column: span 12; }
}
@media (max-width: 560px) {
  .dash-kpis { grid-template-columns: minmax(0, 1fr); }
  .meter-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .meter-list li .meter { grid-column: 1 / -1; grid-row: 2; }
  .chart-box { height: 220px; }
}
@media (forced-colors: active) {
  .meter-fill { fill: CanvasText; }
  .meter-track { fill: Canvas; stroke: CanvasText; }
}
