/* ==========================================================================
   Gestion Stocks & Finances — système de design
   Jetons (couleurs, espacements, typographie), composants, mises en page responsive.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f5;
  --border: #e3e7ed;
  --border-strong: #cfd5de;
  --text: #111827;
  --text-2: #4a5465;
  --text-3: #6b7587;
  --focus: #2a78d6;

  --brand: #2a78d6;
  --brand-600: #256abf;
  --brand-700: #1c5cab;
  --brand-50: #eef5fd;
  --brand-100: #dbe9fb;
  --on-brand: #ffffff;

  --success: #0ca30c;
  --success-text: #006300;
  --success-bg: #e8f6e8;
  --warning: #fab219;
  --warning-text: #8a5a00;
  --warning-bg: #fff5dc;
  --serious: #ec835a;
  --serious-text: #9a3b12;
  --serious-bg: #fdeee6;
  --danger: #d03b3b;
  --danger-text: #b42323;
  --danger-bg: #fdecec;
  --info-text: #1c5cab;
  --info-bg: #eef5fd;
  --neutral-bg: #eef1f5;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e8ecf1;
  --axis: #c2c9d3;

  --sidebar-bg: #0e1627;
  --sidebar-bg-2: #172234;
  --sidebar-text: #c6cfdc;
  --sidebar-text-2: #8391a7;
  --sidebar-active: rgba(255, 255, 255, 0.08);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);

  --sidebar-w: 260px;
  --topbar-h: 60px;
  --bottomnav-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1b2129;
    --surface-3: #222a33;
    --border: #2b333d;
    --border-strong: #3a4450;
    --text: #eef1f5;
    --text-2: #b7c0cc;
    --text-3: #8894a3;
    --brand: #3987e5;
    --brand-600: #4b93ea;
    --brand-700: #7fb2f0;
    --brand-50: #14253b;
    --brand-100: #1b3353;
    --success-text: #4cc34c;
    --success-bg: #12301a;
    --warning-text: #f7c14e;
    --warning-bg: #33280f;
    --serious-text: #f2a07e;
    --serious-bg: #3a2016;
    --danger-text: #f08080;
    --danger-bg: #3a1618;
    --info-text: #7fb2f0;
    --info-bg: #14253b;
    --neutral-bg: #222a33;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #252d37;
    --axis: #3a4450;
    --sidebar-bg: #0a0e14;
    --sidebar-bg-2: #121821;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1b2129;
  --surface-3: #222a33;
  --border: #2b333d;
  --border-strong: #3a4450;
  --text: #eef1f5;
  --text-2: #b7c0cc;
  --text-3: #8894a3;
  --brand: #3987e5;
  --brand-600: #4b93ea;
  --brand-700: #7fb2f0;
  --brand-50: #14253b;
  --brand-100: #1b3353;
  --success-text: #4cc34c;
  --success-bg: #12301a;
  --warning-text: #f7c14e;
  --warning-bg: #33280f;
  --serious-text: #f2a07e;
  --serious-bg: #3a2016;
  --danger-text: #f08080;
  --danger-bg: #3a1618;
  --info-text: #7fb2f0;
  --info-bg: #14253b;
  --neutral-bg: #222a33;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #252d37;
  --axis: #3a4450;
  --sidebar-bg: #0a0e14;
  --sidebar-bg-2: #121821;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* ----------------------------- Base ----------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 23px; letter-spacing: -0.015em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.pos { color: var(--success-text); }
.neg { color: var(--danger-text); }
.strong { font-weight: 600; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.icon { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: -0.25em; }
.icon-sm { width: 15px; height: 15px; flex: none; display: inline-block; vertical-align: -0.2em; }
.icon-lg { width: 22px; height: 22px; flex: none; display: inline-block; vertical-align: -0.3em; }

/* ----------------------------- Application shell ----------------------------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  transition: transform 0.22s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 16px 18px; height: var(--topbar-h); border-bottom: 1px solid rgba(255,255,255,0.06); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #3987e5, #1c5cab); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--sidebar-text-2); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 18px; scrollbar-width: thin; scrollbar-color: #2a3547 transparent; }
.nav-group { margin-top: 14px; }
.nav-group-title { padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sidebar-text-2); }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0; border-radius: 7px;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500; text-decoration: none; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: #5ea0ec; }
.nav-item .icon { opacity: 0.85; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #d03b3b; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.06); font-size: 11.5px; color: var(--sidebar-text-2); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--text-2); position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 0; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.menu-toggle { display: none; }
.day-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 15px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); white-space: nowrap; cursor: pointer;
}
.day-chip .led { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.day-chip.open .led { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.day-chip.pending .led { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.day-chip.closed .led { background: var(--text-3); }
.day-chip.reopened .led { background: var(--serious); box-shadow: 0 0 0 3px var(--serious-bg); }
.net-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 15px; font-size: 12px; font-weight: 600; background: var(--warning-bg); color: var(--warning-text); white-space: nowrap; }
.net-chip.offline { background: var(--danger-bg); color: var(--danger-text); }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.user-btn { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; max-width: 240px; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.user-meta { text-align: left; min-width: 0; line-height: 1.2; }
.user-meta .n { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .r { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content { flex: 1; padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 24px; font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--border); }
.banner.warning { background: var(--warning-bg); color: var(--warning-text); }
.banner.danger { background: var(--danger-bg); color: var(--danger-text); }
.banner.info { background: var(--info-bg); color: var(--info-text); }
.banner .btn { margin-left: auto; }

.scrim { position: fixed; inset: 0; background: rgba(10, 15, 25, 0.45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.bottom-nav { display: none; }
.show-sm { display: none !important; }

/* ----------------------------- Pages ----------------------------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--text-3); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-title h2 { font-size: 15px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); min-height: 54px; flex-wrap: wrap; }
.card-header h2, .card-header h3 { font-size: 14.5px; }
.card-header .hint { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }

/* ----------------------------- Stat tiles ----------------------------- */
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.stat-label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.stat-label .grow { min-width: 0; }
.stat-value-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stat-label .icon-sm { color: var(--text-3); }
.stat-value { font-size: 23px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.15; }
.stat-sub { font-size: 12px; color: var(--text-3); }
.stat.link { cursor: pointer; }
.stat.link:hover { border-color: var(--border-strong); }
.stat .tag { position: absolute; top: 14px; right: 14px; }
.hero-figure { font-size: 40px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }

/* ----------------------------- Buttons ----------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn.disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.success { background: #0e8a0e; border-color: #0e8a0e; color: #fff; }
.btn.success:hover { background: #0b760b; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b82f2f; }
.btn.danger-ghost { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-bg); }
.btn.warning-ghost { color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: transparent; }
.btn.warning-ghost:hover { background: var(--warning-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn .spinner { width: 15px; height: 15px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ----------------------------- Forms ----------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .req { color: var(--danger-text); margin-left: 2px; }
.field .help { font-size: 12px; color: var(--text-3); }
.field .error-text { font-size: 12px; color: var(--danger-text); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 14px; transition: border-color 0.12s, box-shadow 0.12s; min-width: 0;
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; }
.select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c7b76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 16px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); }
.input.sm, .select.sm { height: 32px; font-size: 13px; }
.input.num { text-align: right; }
.input[readonly] { background: var(--surface-2); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .addon { display: grid; place-items: center; padding: 0 11px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 600; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.form-error { padding: 10px 12px; border-radius: var(--radius); background: var(--danger-bg); color: var(--danger-text); font-size: 13px; display: flex; gap: 9px; align-items: flex-start; }
.form-note { padding: 10px 12px; border-radius: var(--radius); background: var(--info-bg); color: var(--info-text); font-size: 13px; display: flex; gap: 9px; align-items: flex-start; }
.form-note.warning { background: var(--warning-bg); color: var(--warning-text); }
.form-note.success { background: var(--success-bg); color: var(--success-text); }

/* ----------------------------- Filters bar ----------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.filters .field.wide { min-width: 220px; }
.filters .spacer { flex: 1; }
.filters-toggle-row { display: none; }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 550; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--brand-50); border-color: var(--brand); color: var(--brand-700); }

/* ----------------------------- Tabs ----------------------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; border: 0; background: transparent; font-size: 13.5px; font-weight: 550; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; text-decoration: none; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.tab .count { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); }
.tab.active .count { background: var(--brand-100); color: var(--brand-700); }

/* ----------------------------- Badges ----------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--neutral-bg); color: var(--text-2); }
.badge .led { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.success { background: var(--success-bg); color: var(--success-text); }
.badge.warning { background: var(--warning-bg); color: var(--warning-text); }
.badge.serious { background: var(--serious-bg); color: var(--serious-text); }
.badge.danger { background: var(--danger-bg); color: var(--danger-text); }
.badge.info { background: var(--info-bg); color: var(--info-text); }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 650; background: var(--surface-3); color: var(--text-2); letter-spacing: 0.02em; }

/* ----------------------------- Tables ----------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-size: 12px; font-weight: 650; color: var(--text-2);
  background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .sort { opacity: 0.4; margin-left: 4px; font-size: 10px; }
.table th.sorted .sort { opacity: 1; color: var(--brand); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table tr.row-muted td { color: var(--text-3); }
.table tr.row-danger td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.table tr.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.table tfoot td { font-weight: 650; background: var(--surface-3); border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table .num { text-align: right; }
.table th.num { text-align: right; }
.table .actions-cell { text-align: right; white-space: nowrap; width: 1%; }
.table .input.sm, .table .select.sm { min-width: 90px; }
.table-compact td, .table-compact th { padding: 7px 10px; }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 12px; color: var(--text-3); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); flex-wrap: wrap; }

/* ----------------------------- Empty / loading ----------------------------- */
.empty { padding: 44px 20px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .icon-lg { display: block; width: 36px; height: 36px; color: var(--border-strong); }
.empty h3 { color: var(--text-2); font-size: 14.5px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px; color: var(--text-3); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.refetching { opacity: 0.55; transition: opacity 0.15s; }

/* ----------------------------- Lists / timelines ----------------------------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .li-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.li-icon.critical { background: var(--danger-bg); color: var(--danger-text); }
.li-icon.warning { background: var(--warning-bg); color: var(--warning-text); }
.li-icon.info { background: var(--info-bg); color: var(--info-text); }
.li-icon.success { background: var(--success-bg); color: var(--success-text); }
.li-title { font-weight: 600; font-size: 13.5px; }
.li-text { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }
.li-meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .t-title { font-size: 13px; font-weight: 600; }
.timeline .t-meta { font-size: 12px; color: var(--text-3); }

.steps { display: flex; gap: 0; align-items: center; margin: 4px 0 0; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.step .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); font-size: 12px; flex: none; }
.step.done { color: var(--text-2); }
.step.done .n { background: var(--success); border-color: var(--success); color: #fff; }
.step.current { color: var(--brand-700); }
.step.current .n { border-color: var(--brand); color: var(--brand-700); background: var(--brand-50); }
.step.blocked .n { border-color: var(--danger); color: var(--danger-text); background: var(--danger-bg); }
.step .bar { flex: 1; height: 2px; background: var(--border); margin: 0 8px; min-width: 16px; }
.step.done .bar { background: var(--success); }
.step:last-child .bar { display: none; }
a.step { text-decoration: none; cursor: pointer; }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 9px 18px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }

.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface-2); }
.callout.warning { border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: var(--warning-bg); color: var(--warning-text); }
.callout.danger { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-bg); color: var(--danger-text); }
.callout.success { border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--success-bg); color: var(--success-text); }
.callout.info { border-color: color-mix(in srgb, var(--brand) 30%, transparent); background: var(--info-bg); color: var(--info-text); }
.callout .c-title { font-weight: 650; }
.callout .c-body { font-size: 13px; margin-top: 2px; }

.meter { height: 8px; border-radius: 4px; background: var(--brand-100); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.meter.warning { background: var(--warning-bg); } .meter.warning > span { background: var(--warning); }
.meter.danger { background: var(--danger-bg); } .meter.danger > span { background: var(--danger); }

.amount-lg { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.diff-box { border-radius: var(--radius-lg); padding: 14px 16px; border: 1px solid var(--border); }
.diff-box.ok { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.diff-box.ko { background: var(--danger-bg); color: var(--danger-text); border-color: transparent; }

/* ----------------------------- Line items editor ----------------------------- */
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 150px 36px; gap: 8px; align-items: start; }
.line.two { grid-template-columns: minmax(0, 1fr) 130px 36px; }
.line-info { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); margin-top: -2px; }
.lines-head { display: grid; gap: 8px; font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.total-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-3); font-weight: 650; }

/* ----------------------------- Modal / drawer ----------------------------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: hidden;
}
dialog.modal.lg { width: min(820px, calc(100vw - 24px)); }
dialog.modal.xl { width: min(1080px, calc(100vw - 24px)); }
dialog.modal.sm { width: min(420px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10, 15, 25, 0.5); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop 0.16s ease-out; display: flex; flex-direction: column; }
@keyframes pop { from { transform: translateY(8px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-head .sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.modal-head .icon-btn { margin: -6px -8px 0 auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 60; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.22s ease; }
.drawer.open { transform: none; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(10, 15, 25, 0.4); z-index: 55; }

.popover { position: absolute; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; border: 0; background: transparent; font-size: 13.5px; text-align: left; cursor: pointer; color: var(--text); text-decoration: none; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.notif-panel { width: min(400px, calc(100vw - 20px)); padding: 0; max-height: 70vh; display: flex; flex-direction: column; }
.notif-panel .list { overflow-y: auto; }

/* ----------------------------- Toasts ----------------------------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 13.5px; animation: slidein 0.2s ease-out; }
.toast .t-icon { color: var(--brand); margin-top: 1px; }
.toast.success .t-icon { color: var(--success); }
.toast.error .t-icon { color: var(--danger); }
.toast.warning .t-icon { color: var(--warning-text); }
.toast .t-title { font-weight: 650; }
.toast .t-msg { color: var(--text-2); font-size: 13px; margin-top: 1px; }
.toast .icon-btn { width: 26px; height: 26px; margin: -3px -5px 0 auto; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ----------------------------- Charts ----------------------------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .label-strong { fill: var(--text); font-weight: 600; }
.chart .label-2 { fill: var(--text-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { transition: opacity 0.12s; }
.chart .bar.dim { opacity: 0.45; }
.chart-tooltip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); border-radius: 9px; padding: 8px 11px; font-size: 12px; min-width: 150px; white-space: nowrap; transform: translate(-50%, -100%); }
.chart-tooltip .tt-title { color: var(--text-3); font-size: 11.5px; margin-bottom: 5px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tooltip .tt-row + .tt-row { margin-top: 3px; }
.chart-tooltip .key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.chart-tooltip .tt-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-name { color: var(--text-2); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend .sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .sw.rect { height: 10px; width: 10px; border-radius: 2px; }
.chart-card .card-body { padding: 14px 18px 16px; }

/* ----------------------------- Dropzone ----------------------------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 32px 20px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone .icon-lg { display: block; width: 34px; height: 34px; margin: 0 auto 8px; color: var(--brand); }

/* ----------------------------- Login ----------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-side { background: radial-gradient(1200px 600px at 10% 10%, #1d3b66 0%, #0f1726 55%), #0f1726; color: #e6ecf5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(94, 160, 236, 0.08); }
.auth-side h1 { font-size: 30px; color: #fff; max-width: 460px; }
.auth-side p { color: #aab6c8; max-width: 440px; margin-top: 12px; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; max-width: 460px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #c9d3e2; font-size: 14px; }
.auth-points .icon { color: #7fb2f0; margin-top: 2px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 22px; }
.auth-card .sub { color: var(--text-3); margin: 6px 0 24px; }

/* ----------------------------- Utilities for print ----------------------------- */
.only-print { display: none; }
@media print {
  .sidebar, .topbar, .bottom-nav, .banner, .no-print, .filters, .page-header .actions, .toasts, .tabs { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff; color: #000; font-size: 11px; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .table th { position: static; }
  .only-print { display: block; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
}

/* ----------------------------- Responsive ----------------------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .user-meta { display: none; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .menu-toggle { display: grid; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 420px) {
  .stat-label .icon-sm { display: none; }
}
@media (max-width: 720px) {
  .filters-toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .filters:not(.open) { display: none; }
  .filters .field, .filters .field.wide { min-width: 0; flex: 1 1 100%; }
  .filters .field[style] { flex: 1 1 calc(50% - 5px); min-width: 0 !important; }
  body { font-size: 14px; }
  .content { padding: 16px 16px calc(var(--bottomnav-h) + 24px); }
  .topbar { padding: 0 12px; gap: 6px; }
  .topbar-title { font-size: 14px; }
  .hide-sm { display: none !important; }
  .show-sm { display: grid !important; }
  .banner { padding: 9px 16px; font-size: 12.5px; flex-wrap: wrap; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 19px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .page-header { align-items: stretch; flex-direction: column; margin-bottom: 16px; }
  .page-header .actions .btn { flex: 1; }
  h1 { font-size: 19px; }
  .filters .field { min-width: calc(50% - 5px); flex: 1; }
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }
  .line { grid-template-columns: minmax(0, 1fr) 90px 36px; }
  .line > .col-type { grid-column: 1 / 3; }
  .modal-body { padding: 16px; }
  dialog.modal { max-height: calc(100vh - 16px); }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  /* Tableaux -> cartes empilées */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td, .table.responsive tfoot { display: block; width: 100%; }
  .table.responsive tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive tbody tr:hover td { background: transparent; }
  .table.responsive td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 16px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-3); font-size: 12px; font-weight: 500; text-align: left; flex: none; max-width: 45%; }
  .table.responsive td.primary-cell { display: block; text-align: left; font-size: 14px; padding-bottom: 5px; }
  .table.responsive td.primary-cell::before { display: none; }
  .table.responsive td.actions-cell { justify-content: flex-end; padding-top: 8px; }
  .table.responsive td.actions-cell::before { display: none; }
  .table.responsive tfoot tr { background: var(--surface-3); }
  .table.responsive td:empty, .table.responsive td:has(> .td-v:empty) { display: none; }
  .table.responsive td > .td-v { min-width: 0; text-align: right; overflow-wrap: anywhere; }
  .table.responsive td.primary-cell > .td-v { text-align: left; }
  .stat-label .grow { overflow-wrap: anywhere; hyphens: auto; }
  .callout { flex-wrap: wrap; }
  .callout > div { flex: 1 1 220px; min-width: 0; }
  .callout > .btn, .callout > .row { flex: 1 1 100%; justify-content: center; }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: var(--bottomnav-h); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border);
  }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-3); text-decoration: none; border: 0; background: transparent; cursor: pointer; }
  .bottom-nav .active { color: var(--brand-700); }
  .toasts { bottom: calc(var(--bottomnav-h) + 10px); right: 12px; }
  .steps .step span.lbl { display: none; }
  .step.current span.lbl { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ----------------------------- Aperçu hébergé ----------------------------- */
.preview-accounts { margin-top: 16px; }
.preview-account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.preview-account-grid .btn { height: auto; min-height: 44px; padding: 7px 10px; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; white-space: normal; }
.gsf-preview [data-print] { display: none !important; }
.preview-pass { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-size: 13px; color: var(--text-2); }
.preview-pass code { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 14px; font-weight: 700; color: var(--text); background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; user-select: all; }
.preview-dock { position: fixed; left: 14px; bottom: 14px; z-index: 80; display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 8px; max-width: calc(100vw - 28px); }
.preview-chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 13px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); cursor: pointer; }
.preview-chip:hover { color: var(--text); border-color: var(--border-strong); }
.preview-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.preview-panel { width: min(340px, calc(100vw - 28px)); max-height: calc(100vh - 90px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.preview-section { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-top: 8px; }
.preview-accounts-list { display: flex; flex-wrap: wrap; gap: 6px; }
.preview-panel .stack-sm { display: flex; flex-direction: column; gap: 6px; }
.gsf-preview .sidebar-foot { padding-bottom: 58px; }
@media (max-width: 720px) {
  .preview-dock { bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom, 0px)); }
}
.table select[data-role-user] { min-width: 235px; }

/* Matrice des droits (cases à cocher) */
.roles-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.roles-matrix .role-check { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.roles-matrix .role-check:disabled { cursor: not-allowed; opacity: 0.6; }
.roles-matrix td.changed { background: var(--warning-bg); }
.roles-matrix thead th { z-index: 1; }

/* ==========================================================================
   Ergonomie : menu réductible, recherche rapide (Ctrl/⌘ K), chargement squelette
   ========================================================================== */
.sidebar-foot { display: flex; align-items: center; gap: 8px; }
.sidebar-foot [data-foot] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collapse-btn { width: 30px; height: 30px; border-radius: 7px; border: 0; background: transparent; color: var(--sidebar-text-2); display: grid; place-items: center; cursor: pointer; flex: none; }
.collapse-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.collapse-btn .icon { transition: transform 0.2s; }
@media (min-width: 961px) {
  body.nav-collapsed { --sidebar-w: 72px; }
  body.nav-collapsed .brand-text, body.nav-collapsed .nav-item span:not(.nav-badge), body.nav-collapsed .sidebar-foot [data-foot] { display: none; }
  body.nav-collapsed .nav-group-title { font-size: 0; height: 1px; margin: 8px 10px; padding: 0; background: rgba(255,255,255,0.08); }
  body.nav-collapsed .sidebar-brand { justify-content: center; padding: 0; }
  body.nav-collapsed .nav-item { justify-content: center; padding: 10px 0; }
  body.nav-collapsed .nav-item .nav-badge { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  body.nav-collapsed .sidebar-foot { justify-content: center; }
  body.nav-collapsed .collapse-btn .icon { transform: rotate(180deg); }
  .sidebar, .main { transition: width 0.2s ease, margin-left 0.2s ease; }
}
@media (max-width: 960px) { .collapse-btn { display: none; } }

.search-trigger { display: inline-flex; align-items: center; gap: 8px; height: 34px; min-width: 240px; padding: 0 8px 0 11px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); font-size: 13px; cursor: pointer; margin-left: 12px; }
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger .grow { text-align: left; }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface); font-size: 11px; font-weight: 600; color: var(--text-3); font-family: var(--font); }
@media (max-width: 1180px) { .search-trigger { min-width: 0; } .search-trigger .grow, .search-trigger .kbd { display: none; } }

.palette-scrim { position: fixed; inset: 0; z-index: 95; background: rgba(10, 15, 25, 0.42); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; animation: fadein 0.12s ease; }
.palette { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 72vh; animation: pop 0.14s ease; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input .icon { color: var(--text-3); }
.palette-input input { flex: 1; height: 54px; border: 0; outline: 0; background: transparent; font-size: 15.5px; color: var(--text); }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-section { padding: 10px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.palette-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.palette-item .icon-sm { color: var(--text-3); }
.palette-item .p-sub { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.palette-item.on { background: var(--brand-50); }
.palette-item.on .icon-sm { color: var(--brand-700); }
.palette-empty { padding: 28px 16px; text-align: center; color: var(--text-3); }
.palette-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 11.5px; color: var(--text-3); }
.palette-foot span { display: inline-flex; align-items: center; gap: 5px; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.skeleton { display: flex; flex-direction: column; gap: 16px; }
.sk { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.sk-title { height: 26px; width: 260px; }
.sk-sub { height: 14px; width: 420px; max-width: 80%; margin-top: -8px; }
.sk-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.sk-card { height: 96px; }
.sk-block { height: 280px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.content > * { animation: pagein 0.16s ease; }
@keyframes pagein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .content > *, .sk, .palette, .palette-scrim { animation: none; } }

.card { transition: border-color 0.15s; }

/* Actions de ligne discrètes : visibles au survol de la ligne (toujours visibles sur écran tactile) */
.row-action { color: var(--text-3); }
.table tbody tr .row-action:hover { color: var(--danger-text); background: var(--danger-bg); }
@media (hover: hover) and (min-width: 721px) {
  .table tbody tr .row-action { opacity: 0; transition: opacity 0.12s; }
  .table tbody tr:hover .row-action, .table tbody tr .row-action:focus-visible { opacity: 1; }
}

/* Bilan de stand (inventaire) */
.stand-sold { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0; padding: 10px 12px; border-radius: var(--radius-sm, 8px); background: var(--surface-2); border: 1px solid var(--border); }
.stand-sold strong { font-size: 20px; }
.table tr.row-selected td { background: color-mix(in srgb, var(--brand) 7%, transparent); }

/* Aperçu de l'en-tête des exports (Paramètres › Entreprise) */
.export-preview .ep-box { display: flex; gap: 12px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface-2); margin-top: 6px; }
.export-preview .ep-bar { width: 4px; border-radius: 2px; background: var(--brand); flex: none; }
.export-preview .ep-name { font-weight: 650; font-size: 15px; }
.export-preview .ep-line { font-size: 12px; color: var(--text-2); line-height: 1.5; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
