/* ==========================================================================
   Caregest — design system
   Identité : indigo (confiance, sérieux) + touche corail ; fond gris-lavande pour que les cartes
   ressortent ; menu indigo profond. Grille de 8 px · rayons 10–14 px · couleurs d'alerte réservées au métier,
   toujours accompagnées d'un texte (jamais la couleur seule).
   ========================================================================== */

:root {
  /* Marque */
  --brand: #4F46E5;        /* indigo : contraste 6,3:1 avec le blanc */
  --brand-700: #4338CA;
  --brand-900: #1E1B4B;
  --brand-50: #EEF0FF;
  --brand-100: #DDE1FF;
  --accent: #FB7C4F;       /* corail : repères visuels (compteurs, progression), texte foncé dessus */
  --accent-50: #FFEDE5;

  --bg: #E9ECF5;           /* gris-lavande : fond de page */
  --surface: #FFFFFF;
  --surface-2: #F2F4FA;
  --text: #14172B;
  --text-2: #565D78;
  --text-3: #8A90A8;
  --border: #D6DAE8;
  --border-strong: #BCC2D6;
  /* Noms historiques (« blue ») conservés dans le code : ils portent désormais la couleur de marque. */
  --blue: var(--brand);
  --blue-600: var(--brand-700);
  --blue-50: var(--brand-50);
  --blue-100: var(--brand-100);
  --green: #16A34A;
  --green-50: #F0FDF4;
  --green-700: #15803D;
  --amber: #D97706;
  --amber-50: #FFFBEB;
  --amber-700: #B45309;
  --red: #DC2626;
  --red-50: #FEF2F2;
  --red-700: #B91C1C;

  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .18), 0 4px 8px -4px rgba(15, 23, 42, .08);
  --ring: 0 0 0 3px rgba(79, 70, 229, .3);

  --sb-w: 264px;
  --sb-w-collapsed: 76px;
  --hd-h: 64px;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; line-height: 34px; font-weight: 750; letter-spacing: -.02em; }
h2 { font-size: 18px; line-height: 28px; font-weight: 650; }
h3 { font-size: 15px; line-height: 24px; font-weight: 650; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; line-height: 20px; }
.xs { font-size: 12px; line-height: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.num, .qty { font-variant-numeric: tabular-nums; }
.qty { font-weight: 650; }
.loading { padding: 32px; text-align: center; color: var(--text-2); }

/* ---------- Icônes ---------- */
.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 22px; height: 22px; }
.ic.xl { width: 28px; height: 28px; }

/* ==========================================================================
   Coque : sidebar + en-tête
   ========================================================================== */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); transition: grid-template-columns .18s ease; }
.app.collapsed { grid-template-columns: var(--sb-w-collapsed) minmax(0, 1fr); }

.sb {
  --surface: var(--brand-900); --surface-2: rgba(255, 255, 255, .08); --text: #FFFFFF; --text-2: rgba(255, 255, 255, .74); --text-3: rgba(255, 255, 255, .5);
  --border: rgba(255, 255, 255, .1); --blue-50: rgba(255, 255, 255, .13); --blue-600: #FFFFFF; --blue: var(--accent);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); color: var(--text); z-index: 30;
  overflow-y: auto; scrollbar-width: thin;
}
.sb select option { color: #13231F; }
.sb-brand { height: var(--hd-h); display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--border); flex: none; }
.sb-logo { width: 32px; height: 32px; border-radius: 9px; background: #fff; color: var(--brand); display: grid; place-items: center; flex: none; }
.sb-logo img { width: 24px; height: 24px; display: block; }
.sb-name { font-weight: 700; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.sb-name small { display: block; font-size: 11px; font-weight: 500; color: var(--text-2); letter-spacing: 0; margin-top: -2px; }
.sb-nav { flex: 1 0 auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-sep { border-top: 1px solid var(--border); margin: 10px 12px; }
.sb-section { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 16px 12px 6px; }
.sb-link { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: var(--r); color: var(--text-2); font-weight: 550; font-size: 14px; text-decoration: none; position: relative; white-space: nowrap; }
.sb-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sb-link.on { background: var(--blue-50); color: var(--blue-600); }
.sb-link.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue); }
.sb-link .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #2A1205; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.sb-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 21px; padding-left: 12px; border-left: 1px solid var(--border); }
.sb-sub .sb-link { min-height: 34px; font-size: 13.5px; font-weight: 500; }
.sb-sub .sb-link.on::before { display: none; }
.sb-foot { border-top: 1px solid var(--border); padding: 12px; flex: none; }
.sb-site { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); background: var(--surface-2); margin-bottom: 8px; min-width: 0; }
.sb-site .ic { color: var(--text-2); }
.sb-site .txt > span { display: block; }
.sb-site b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-site select { width: 100%; border: 0; background: transparent; font-weight: 650; font-size: 13px; padding: 0; min-height: 0; cursor: pointer; }
.sb-user { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r); border: 0; background: none; cursor: pointer; text-align: left; min-width: 0; }
.sb-user:hover { background: var(--surface-2); }
.sb-user .who { min-width: 0; flex: 1; }
.sb-user .who b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user .who span { display: block; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-collapse { margin-top: 8px; width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; color: var(--text-2); border-radius: var(--r); cursor: pointer; font-size: 13px; }
.sb-collapse:hover { background: var(--surface-2); color: var(--text); }
.demo-chip { margin: 0 12px 8px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--amber-50); color: var(--amber-700); font-size: 12px; font-weight: 600; display: flex; gap: 6px; align-items: center; }

.app.collapsed .sb-name, .app.collapsed .sb-section, .app.collapsed .sb-link .lbl, .app.collapsed .sb-sub,
.app.collapsed .sb-site .txt, .app.collapsed .sb-user .who, .app.collapsed .sb-collapse .lbl, .app.collapsed .demo-chip .lbl { display: none; }
.app.collapsed .sb-brand { padding: 0; justify-content: center; }
.app.collapsed .sb-link { justify-content: center; padding: 0; }
.app.collapsed .sb-link .count { position: absolute; top: 2px; right: 6px; min-width: 18px; height: 16px; font-size: 10px; }
.app.collapsed .sb-site, .app.collapsed .sb-user, .app.collapsed .sb-collapse { justify-content: center; }
.app.collapsed .demo-chip { justify-content: center; margin: 0 8px 8px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-100); color: var(--blue-600); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.hd { position: sticky; top: 0; z-index: 20; height: var(--hd-h); display: flex; align-items: center; gap: 12px; padding: 0 32px; background: rgba(233, 236, 245, .9); backdrop-filter: saturate(1.4) blur(6px); border-bottom: 1px solid var(--border); }
.hd .hd-menu { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-2); min-width: 0; white-space: nowrap; }
.crumbs b { color: var(--text); font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.crumbs > span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumbs .ic { width: 14px; height: 14px; color: var(--text-3); }
.hd-spacer { flex: 1; }

.search { position: relative; width: min(420px, 38vw); }
.search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.hd .search input[type=search] { width: 100%; height: 40px; min-height: 40px; padding: 0 44px 0 38px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); }
.search input:focus { border-color: var(--blue); box-shadow: var(--ring); outline: none; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 600 11px/1 var(--font); color: var(--text-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; background: var(--surface); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow: auto; z-index: 60; }
.sr-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r); cursor: pointer; }
.sr-item.active, .sr-item:hover { background: var(--blue-50); }
.sr-item .grow { min-width: 0; flex: 1; }
.sr-item b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-item span.sub { font-size: 12px; color: var(--text-2); }
.sr-empty { padding: 16px; text-align: center; color: var(--text-2); font-size: 14px; }

.iconbtn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; flex: none; }
.iconbtn:hover { color: var(--text); border-color: var(--border-strong); }
.iconbtn .dot { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }
.hd-user { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }

.menu { position: absolute; z-index: 70; min-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; }
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; text-align: left; font-size: 14px; color: var(--text); }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item .ic { color: var(--text-2); }
.menu-item.danger, .menu-item.danger .ic { color: var(--red); }

.notif { width: 380px; max-width: calc(100vw - 24px); padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 420px; overflow: auto; padding: 6px; }
.notif-item { display: flex; gap: 12px; padding: 10px; border-radius: var(--r); cursor: pointer; align-items: flex-start; }
.notif-item:hover { background: var(--surface-2); }
.notif-item .sev { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }

.content { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 32px; }

/* ==========================================================================
   Composants
   ========================================================================== */

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn.danger { color: var(--red); border-color: #FECACA; }
.btn.danger:hover { background: var(--red-50); }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-solid:hover { background: var(--red-700); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { background: var(--green-700); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn.lg { min-height: 48px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Champs */
label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
label .opt { font-weight: 500; color: var(--text-3); }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--blue); margin: 0; flex: none; }
.field { margin-bottom: 16px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.field.has-error input:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
.field-error { display: flex; gap: 6px; align-items: center; color: var(--red); font-size: 13px; margin-top: 6px; }
.field-error .ic { width: 14px; height: 14px; }
.hint { font-size: 12.5px; color: var(--text-2); margin-top: 6px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; font-size: 14px; margin: 8px 0; cursor: pointer; }
.cols { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.only-sm { display: none !important; }
.cols3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.cols > div > .field, .cols3 > div > .field { margin-bottom: 0; }
.input-affix { position: relative; }
.input-affix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-size: 14px; pointer-events: none; }
.input-affix input[type=number] { padding-right: 36px; }
.form-section { padding: 20px 0; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section > h3 { margin-bottom: 4px; }
.form-section > .muted { font-size: 13px; margin-bottom: 16px; }

/* Segmenté (entrée / sortie, filtres compacts) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border-radius: var(--r); border: 1px solid var(--border); }
.seg button { border: 0; background: none; min-height: 34px; padding: 0 14px; border-radius: 7px; font-weight: 600; font-size: 13.5px; color: var(--text-2); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.on.in { color: var(--green-700); }
.seg button.on.out { color: var(--red-700); }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 20px; margin-bottom: 24px; }
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card-head h2 { font-size: 17px; }
.card-head .sub { font-size: 13px; color: var(--text-2); }
.card-head .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }

/* Tête de page */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head p { color: var(--text-2); margin: 2px 0 0; font-size: 14px; max-width: 640px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.date-chip { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 4px 12px; margin-left: 8px; vertical-align: middle; font-weight: 500; }

/* KPI */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); text-align: left; color: inherit; text-decoration: none; min-height: 132px; }
button.stat, a.stat { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
button.stat:hover, a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.stat-top { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.stat-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.stat-val { font-size: 30px; line-height: 38px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-val small { font-size: 15px; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.stat-foot { display: block; font-size: 12.5px; color: var(--text-2); margin-top: auto; }
.stat-go { position: absolute; top: 18px; right: 16px; color: var(--text-3); }
.stat.crit .stat-ico { background: var(--red-50); color: var(--red); }
.stat.warn .stat-ico { background: var(--amber-50); color: var(--amber); }
.stat.info .stat-ico { background: var(--blue-50); color: var(--blue); }
.stat.okay .stat-ico { background: var(--green-50); color: var(--green); }
.stat.crit .stat-val { color: #8F1414; }
.stat.crit { background: #F8C4BF; border-color: #EE9F98; }
.stat.warn { background: #FCD98F; border-color: #EDBB55; }
.stat.okay { background: #B9E6CB; border-color: #86D0A5; }
.stat.info { background: #C9D2FF; border-color: #A3B0F5; }
.stat.crit .stat-ico, .stat.warn .stat-ico, .stat.okay .stat-ico, .stat.info .stat-ico { background: rgba(255, 255, 255, .8); }
.stat .stat-top, .stat .stat-foot { color: var(--text); opacity: .85; }
.stat.crit .stat-ico { color: #B42318; } .stat.warn .stat-ico { color: #B45309; } .stat.okay .stat-ico { color: #15803D; }
.stat:hover { box-shadow: var(--shadow); transform: translateY(-1px); transition: transform .12s, box-shadow .12s; }

/* Badges & statuts */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid transparent; }
.badge .ic { width: 13px; height: 13px; }
.badge.green { background: var(--green-50); color: var(--green-700); border-color: #BBF7D0; }
.badge.amber { background: var(--amber-50); color: var(--amber-700); border-color: #FDE68A; }
.badge.red { background: var(--red-50); color: var(--red-700); border-color: #FECACA; }
.badge.blue { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-100); }
.badge.outline { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.tag .ic { width: 14px; height: 14px; }

/* Tableaux */
.tbl-wrap, .tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th button.sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
th button.sort:hover { color: var(--text); }
th button.sort .ic { width: 13px; height: 13px; opacity: .5; }
th button.sort.on { color: var(--blue-600); }
th button.sort.on .ic { opacity: 1; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #FAFBFD; }
tr.row-click { cursor: pointer; }
.arow.row-click { cursor: pointer; }
.arow.row-click:hover { background: var(--surface-2); }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.cell-prod { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.prod-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; flex: none; }
.qty-big { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.qty-sub { font-size: 12px; color: var(--text-2); }
.table-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.table-toolbar .search-inline { position: relative; flex: 1 1 260px; max-width: 360px; }
.table-toolbar .search-inline .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.table-toolbar .search-inline input[type=search] { padding-left: 38px; min-height: 40px; }
.table-toolbar select { width: auto; min-height: 40px; min-width: 170px; }
.pager { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; color: var(--text-2); }

/* Contrôle de quantité −/+ */
.qc { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.qc button { width: 36px; height: 36px; border: 0; border-radius: 7px; background: none; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.qc button:hover { background: var(--surface-2); color: var(--text); }
.qc button.minus:hover { background: var(--red-50); color: var(--red); }
.qc button.plus:hover { background: var(--green-50); color: var(--green); }
.qc button:disabled { opacity: .35; cursor: not-allowed; background: none; color: var(--text-3); }
.qc .val { min-width: 44px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }

/* Popover d'ajustement */
.pop { position: absolute; z-index: 80; width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.pop-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.pop-head .kind { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.pop-head .kind.in { background: var(--green-50); color: var(--green); }
.pop-head .kind.out { background: var(--red-50); color: var(--red); }
.pop-body { padding: 16px; }
.pop-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); background: #FBFCFE; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper input { text-align: center; font-weight: 700; font-size: 18px; width: 100%; }
.stepper button { width: 44px; height: 44px; flex: none; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--text-2); }
.stepper button:hover { background: var(--surface-2); color: var(--text); }
.preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); font-size: 13.5px; margin-top: 12px; }
.preview b { font-variant-numeric: tabular-nums; }
.confirm-box { padding: 12px; border-radius: var(--r); background: var(--amber-50); border: 1px solid #FDE68A; color: var(--amber-700); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; }
.confirm-box.danger { background: var(--red-50); border-color: #FECACA; color: var(--red-700); }

/* Tiroir latéral (fiche produit, formulaire) */
.drawer-overlay { position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .35); display: flex; justify-content: flex-end; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer { width: min(560px, 100vw); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 20px; line-height: 28px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer th, .drawer td { padding: 10px 12px; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); background: #FBFCFE; }

/* Modale */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease-out; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-lg); animation: pop .16s ease-out; }
.modal > h2 { margin-bottom: 16px; font-size: 19px; }

/* Résumés de quantités (fiche produit) */
.qtys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.qtys > div { border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.qtys .lbl { font-size: 12px; color: var(--text-2); font-weight: 600; }
.qtys .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.qtys .v small { font-size: 13px; color: var(--text-2); font-weight: 500; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

/* Liste d'alertes priorisées */
.alist { display: flex; flex-direction: column; }
.arow { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.arow:last-child { border-bottom: 0; }
.arow .sev { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.sev.crit { background: var(--red-50); color: var(--red); }
.sev.warn { background: var(--amber-50); color: var(--amber); }
.sev.info { background: var(--blue-50); color: var(--blue); }
.sev.ok { background: var(--green-50, #ECFDF5); color: var(--green-700); }
.arow .grow { flex: 1; min-width: 0; }
.arow .title { font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.arow .meta { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.arow .act { display: flex; gap: 8px; flex: none; }

/* États vides, squelettes */
.empty { text-align: center; padding: 48px 24px; }
.empty .em-ico { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.empty .em-ico.ok { background: var(--green-50); color: var(--green); }
.empty h3 { font-size: 16px; margin-bottom: 4px; }
.empty p { color: var(--text-2); max-width: 420px; margin: 0 auto 16px; font-size: 14px; }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, #E9EEF5 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: var(--r-sm); }
@keyframes sk { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* Notifications (toasts) */
.toasts { position: fixed; z-index: 200; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: var(--r); background: var(--text); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; animation: pop .16s ease-out; }
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: #4ADE80; }
.toast.bad { background: var(--red-700); }
.toast button { margin-left: auto; border: 0; background: none; color: rgba(255,255,255,.75); cursor: pointer; padding: 0 0 0 8px; font-weight: 600; }

/* Bandeaux */
.banner, .notice { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--r); margin-bottom: 20px; font-size: 14px; font-weight: 500; background: var(--amber-50); color: var(--amber-700); border: 1px solid #FDE68A; }
.banner.bad, .notice.bad { background: var(--red-50); color: var(--red-700); border-color: #FECACA; }
.banner a, .notice a { color: inherit; font-weight: 700; text-decoration: underline; }
/* Bandeau d'installation : fin et discret (les avis métier gardent le gabarit .notice). */
.banner { padding: 8px 14px; margin-bottom: 14px; font-size: 13px; }
.err { display: flex; gap: 8px; align-items: center; background: var(--red-50); color: var(--red-700); border: 1px solid #FECACA; padding: 10px 14px; border-radius: var(--r); margin: 12px 0; font-size: 14px; }
.ok { display: flex; gap: 8px; align-items: center; background: var(--green-50); color: var(--green-700); border: 1px solid #BBF7D0; padding: 10px 14px; border-radius: var(--r); margin: 12px 0; font-size: 14px; }

/* Onglets */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 20px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--blue-600); border-bottom-color: var(--blue); }

/* Rangées génériques (écrans repris) */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row > select { width: auto; flex: 1 1 160px; }
.item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.timeline-day { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 16px 20px 6px; }
.tl { display: flex; gap: 14px; padding: 10px 20px; align-items: flex-start; }
.tl .tl-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.tl .grow { flex: 1; min-width: 0; font-size: 14px; }
.tl time { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

/* Scan */
.scanbox { position: relative; background: #0B1220; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 4 / 3; max-height: 46vh; margin-bottom: 12px; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; }
.scanbox .aim { position: absolute; inset: 26% 14%; border: 2px solid rgba(255, 255, 255, .9); border-radius: 12px; box-shadow: 0 0 0 999px rgba(11, 18, 32, .45); }

/* Authentification */
.loginpage, .install { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 500px at 50% -10%, var(--blue-50), transparent 70%), var(--bg); }
.login-card, .install-card { width: 100%; max-width: 440px; padding: 32px; }
.install-card { max-width: 560px; }
.login-card h1, .install-card h1 { font-size: 24px; margin: 12px 0 4px; }
.logo { width: 44px; height: 44px; }
.brandmark { display: inline-flex; width: 48px; height: 48px; border-radius: 12px; background: #fff; border: 1px solid var(--border); align-items: center; justify-content: center; }
.brandmark img { display: block; }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }
.install label { margin-top: 12px; }
.install h2 { margin-top: 20px; font-size: 16px; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* Superposition mobile de la sidebar */
.sb-scrim { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
/* Colonnes secondaires des tableaux larges (ex. « Dernier mouvement ») : seulement sur grand écran. */
@media (max-width: 1499px) { .hide-xl { display: none !important; } }
@media (max-width: 1279px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 24px; }
  .hd { padding: 0 24px; }
  .hide-lg { display: none !important; }
}
@media (max-width: 1100px) {
  /* Tablette : sidebar compacte (icônes), zones tactiles larges */
  .app, .app.collapsed { grid-template-columns: var(--sb-w-collapsed) minmax(0, 1fr); }
  .app .sb-name, .app .sb-section, .app .sb-link .lbl, .app .sb-sub, .app .sb-site .txt, .app .sb-user .who, .app .sb-collapse, .app .demo-chip .lbl { display: none; }
  .app .sb-brand { padding: 0; justify-content: center; }
  .app .sb-link { justify-content: center; padding: 0; min-height: 48px; }
  .app .sb-link .count { position: absolute; top: 4px; right: 6px; min-width: 18px; height: 16px; font-size: 10px; }
  .app .sb-site, .app .sb-user { justify-content: center; }
  .app .demo-chip { justify-content: center; margin: 0 8px 8px; }
  .search { width: auto; flex: 1; max-width: 420px; }
  .search kbd { display: none; }
  .hide-md { display: none !important; }
  .btn { min-height: 44px; }
  .qc button { width: 44px; height: 44px; }
  .grid.two { grid-template-columns: 1fr; }
  td { padding: 12px 10px; }
  th { padding: 10px; }
  .cell-prod { min-width: 170px; }
  .prod-ico { display: none; }
}
@media (max-width: 767px) {
  /* Mobile : sidebar en tiroir, cartes empilées */
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sb { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .sb { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .sb-scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 25; }
  .app .sb-name, .app .sb-section, .app .sb-link .lbl, .app .sb-sub, .app .sb-site .txt, .app .sb-user .who, .app .demo-chip .lbl { display: revert; }
  .app .sb-link { justify-content: flex-start; padding: 0 12px; }
  .app .sb-link .count { position: static; margin-left: auto; }
  .app .sb-brand { padding: 0 20px; justify-content: flex-start; }
  .app .sb-site, .app .sb-user { justify-content: flex-start; }
  .app .sb-sub { display: flex; }
  .hd { padding: 0 12px; gap: 8px; }
  .hd .hd-menu { display: grid; }
  .crumbs { display: none; }
  .search { max-width: none; }
  .content { padding: 16px; }
  h1 { font-size: 24px; line-height: 32px; }
  .stats { gap: 12px; }
  .stat { min-height: 116px; padding: 14px 16px; }
  .stat-val { font-size: 26px; }
  .stat-go { display: none; }
  .cols, .cols3, .qtys { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .arow { flex-wrap: wrap; padding: 14px 16px; }
  /* Action compacte, alignée sous le texte : pas de mur de boutons pleine largeur. */
  .arow .act { width: 100%; padding-left: 50px; }
  .btn.only-sm { display: flex !important; }
  .table-toolbar { padding: 12px; }
  .table-toolbar select { flex: 1; min-width: 0; }
  .pop { position: fixed; left: 8px !important; right: 8px; bottom: 8px; top: auto !important; width: auto; }
  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }
  .kv { grid-template-columns: 1fr; }
  /* Tableau → cartes */
  .tbl-cards thead { display: none; }
  .tbl-cards tr { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .tbl-cards td { border: 0; padding: 0; }
  .tbl-cards td.c-hide { display: none; }
  .tbl-cards td.c-prod { grid-column: 1 / -1; }
  .tbl-cards td.c-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
  .tbl-cards td.c-full { grid-column: 1 / -1; order: 5; }
  .tbl-cards td.c-start { text-align: left; }
  .only-sm { display: block !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Tableau de bord : bandeau « Bien démarrer » ---------- */
.onboard { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 20px; border-radius: var(--r-lg); background: var(--brand-900); color: #fff; }
.onboard .ob-title { font-weight: 700; }
.onboard .ob-sub { font-size: 13px; color: rgba(255, 255, 255, .75); }
.onboard .ob-bar { flex: 1; min-width: 120px; max-width: 220px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.onboard .ob-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.onboard .btn { background: #fff; border-color: #fff; color: var(--brand-900); }
.onboard .btn.ghost { background: transparent; border-color: transparent; color: rgba(255, 255, 255, .8); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.hello-date { text-transform: capitalize; }

/* ---------- Aide « Comment faire ? » ---------- */
.help-search input[type=search] { width: 100%; height: 44px; padding: 0 12px 0 38px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); }
.help-search { width: 100%; max-width: none; margin-bottom: 16px; }
.help-chips { display: flex; flex-direction: column; gap: 8px; }
.help-chip { text-align: left; min-height: 44px; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.help-chip:hover { background: var(--blue-50); border-color: var(--blue); }
.help-card { padding: 16px; margin-bottom: 12px; border-radius: var(--r-lg, 12px); border: 1px solid var(--border); background: var(--surface); }
.help-card h3 { margin: 0 0 8px; font-size: 16px; }
.help-card ol { margin: 0 0 12px; padding-left: 20px; color: var(--text-2); font-size: 14px; }
.help-card li + li { margin-top: 6px; }

/* ---------- Compte de démonstration (lecture seule) ---------- */
.readonly-bar { display: flex; gap: 8px; align-items: center; padding: 8px 24px; background: var(--brand-900, #1E1B4B); color: #fff; font-size: 13px; font-weight: 600; }
.invite-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 22px; font-weight: 700; letter-spacing: .08em; padding: 12px 16px; border-radius: var(--r); background: var(--blue-50); border: 1px dashed var(--blue); text-align: center; margin: 12px 0; }
