/* =====================================================================
   LEXIA Design System — v4
   Bleu nuit · bleu électrique · blanc cassé · touches turquoise
   Aucun style en ligne (CSP stricte) : tout passe par ces classes.
   ===================================================================== */

:root {
  /* Palette de marque */
  --navy-950: #060E22;
  --navy-900: #0B1B3B;
  --navy-800: #13264D;
  --navy-700: #1C3466;
  --electric-600: #1D4ED8;
  --electric-500: #2563EB;
  --electric-400: #3B82F6;
  --electric-100: #DBEAFE;
  --teal-500: #14B8A6;
  --teal-400: #2DD4BF;
  --teal-100: #CCFBF1;
  --ivory-50: #FAF9F6;
  --ivory-100: #F4F2EC;

  /* Thème clair (par défaut) */
  --bg: #F5F4F0;
  --bg-elevated: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F8F7F3;
  --surface-3: #EFEDE6;
  --border: #E4E1D8;
  --border-strong: #CFCBBF;
  --text: #0E1A33;
  --text-2: #3D4A63;
  --text-3: #6B7488;
  --primary: var(--electric-500);
  --primary-hover: var(--electric-600);
  --primary-soft: #E8F0FE;
  --primary-text: #FFFFFF;
  --accent: var(--teal-500);
  --accent-soft: #E3F8F4;
  --success: #15803D;
  --success-soft: #E6F6EC;
  --warning: #B45309;
  --warning-soft: #FDF2E2;
  --danger: #B91C1C;
  --danger-soft: #FDECEC;
  --info: #1D4ED8;
  --info-soft: #E8F0FE;
  --sidebar-bg: var(--navy-900);
  --sidebar-text: #C8D3EA;
  --sidebar-muted: #7F8DAE;
  --sidebar-active: rgba(59, 130, 246, 0.16);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.35);
  --shadow-sm: 0 1px 2px rgba(11, 27, 59, 0.06);
  --shadow: 0 1px 2px rgba(11, 27, 59, 0.05), 0 4px 16px rgba(11, 27, 59, 0.06);
  --shadow-lg: 0 12px 40px rgba(11, 27, 59, 0.18);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #070D1D;
  --bg-elevated: #0E1730;
  --surface: #0F1833;
  --surface-2: #131E3D;
  --surface-3: #1A2749;
  --border: #22305A;
  --border-strong: #2E3F70;
  --text: #E7ECF6;
  --text-2: #B5C0D8;
  --text-3: #8592B0;
  --primary: var(--electric-400);
  --primary-hover: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --accent: var(--teal-400);
  --accent-soft: rgba(45, 212, 191, 0.12);
  --success: #4ADE80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --info: #60A5FA;
  --info-soft: rgba(96, 165, 250, 0.13);
  --sidebar-bg: #050B1A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; border-right: 1px solid rgba(255, 255, 255, .04); z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--electric-500), var(--teal-500)); box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
}
.brand-mark svg { width: 20px; height: 20px; color: #fff; }
.brand-name { font-weight: 800; letter-spacing: .14em; font-size: 15px; }
.brand-sub { font-size: 10px; letter-spacing: .18em; color: var(--sidebar-muted); text-transform: uppercase; }
.tenant-switch {
  margin: 4px 12px 10px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06); display: flex; gap: 10px; align-items: center; cursor: pointer; color: inherit;
  font: inherit; text-align: left; width: calc(100% - 24px);
}
.tenant-switch:hover { background: rgba(255, 255, 255, .07); }
.tenant-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-400); box-shadow: 0 0 0 3px rgba(45, 212, 191, .18); flex: none; }
.tenant-name { color: #fff; font-weight: 600; font-size: 13px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--sidebar-muted); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500; position: relative; transition: background .15s var(--ease), color .15s;
}
.nav-item svg { width: 18px; height: 18px; opacity: .85; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, .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: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--electric-400); }
.nav-badge { margin-left: auto; background: var(--teal-500); color: #022; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 11.5px; color: var(--sidebar-muted); display: flex; justify-content: space-between; align-items: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.icon-btn.menu-toggle { display: none; }
.global-search { flex: 1; max-width: 560px; position: relative; }
.global-search input {
  width: 100%; height: 38px; padding: 0 12px 0 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.global-search > svg { position: absolute; left: 12px; top: 10px; width: 18px; height: 18px; color: var(--text-3); }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--text-3); }
.global-search .kbd { position: absolute; right: 10px; top: 9px; }
.search-pop {
  position: absolute; top: 44px; left: 0; right: 0; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow: auto;
}
.search-pop a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); align-items: center; }
.search-pop a:hover, .search-pop a.sel { background: var(--surface-2); text-decoration: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: inline-grid; place-items: center; cursor: pointer; position: relative; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.dot-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--navy-700), var(--electric-500)); flex: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 22px; cursor: pointer; border: 1px solid transparent; background: none; color: inherit; font: inherit; }
.user-chip:hover { background: var(--surface); border-color: var(--border); }
.user-chip .who { line-height: 1.15; text-align: left; }
.user-chip .who small { display: block; color: var(--text-3); font-size: 11.5px; }
.timer-pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 17px; background: var(--accent-soft); color: var(--accent); font-weight: 600; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); cursor: pointer; font: inherit; }
.timer-pill .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(20, 184, 166, .5); } 70% { box-shadow: 0 0 0 8px rgba(20, 184, 166, 0); } 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, 0); } }

.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; animation: fadeIn .25s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.page-head .sub { color: var(--text-3); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-3); }

/* ---------- Grilles ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 6px; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.card-head h2 svg, .card-head h3 svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.tenant-switch > svg { width: 16px; height: 16px; flex: none; opacity: .7; }
.tenant-switch .grow { flex: 1; min-width: 0; }
.page-head h1 svg { width: 22px; height: 22px; }
.list-item > svg, .row > svg { width: 18px; height: 18px; flex: none; }
.empty p { max-width: 420px; margin: 0 auto; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card.hero {
  background: radial-gradient(1200px 300px at 100% 0%, rgba(45, 212, 191, .22), transparent 60%),
              linear-gradient(120deg, var(--navy-900), var(--navy-700) 60%, var(--electric-600));
  color: #fff; border: none; box-shadow: var(--shadow);
}
.card.hero .muted, .card.hero .sub { color: rgba(220, 230, 250, .75); }
.card.hero h1 { color: #fff; }

/* KPI */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi-label { font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--text-3); }
.delta { font-weight: 700; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--text-3); background: var(--surface-3); }
.kpi .spark { position: absolute; right: 12px; bottom: 10px; opacity: .9; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); position: absolute; right: 14px; top: 14px; }
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-icon.teal { background: var(--accent-soft); color: var(--accent); }
.kpi-icon.warn { background: var(--warning-soft); color: var(--warning); }
.kpi-icon.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 13.5px var(--font); cursor: pointer;
  transition: background .15s var(--ease), border-color .15s, transform .05s, box-shadow .15s; white-space: nowrap; text-decoration: none !important;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #032; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn[disabled], .btn.loading { opacity: .55; cursor: not-allowed; }
.btn.loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.btn-group button { border: none; background: var(--surface); padding: 0 12px; height: 34px; font: 600 12.5px var(--font); color: var(--text-2); cursor: pointer; }
.btn-group button + button { border-left: 1px solid var(--border); }
.btn-group button.active { background: var(--primary-soft); color: var(--primary); }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 11.5px; color: var(--text-3); }
.field .err { font-size: 12px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: 38px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 9px; padding: 0 11px; font: inherit; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: var(--focus); outline: none; }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar .select { height: 34px; width: auto; min-width: 160px; }
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 22px; text-align: center; color: var(--text-3);
  background: var(--surface-2); transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone svg { width: 26px; height: 26px; margin-bottom: 6px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow: auto; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1;
}
.table th.sortable { cursor: pointer; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .sub { display: block; font-size: 12px; color: var(--text-3); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 12px; font-size: 12px; background: var(--surface-3); color: var(--text-2); }
.chip .swatch { width: 8px; height: 8px; border-radius: 50%; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 10px 14px; border: none; background: none; color: var(--text-3); font: 600 13.5px var(--font); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-3); border-radius: 8px; padding: 0 6px; }

/* ---------- Modales, panneaux, toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(6, 14, 34, .48); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; animation: fadeIn .15s; padding: 20px; }
.modal { background: var(--bg-elevated); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.modal.lg { width: min(860px, 100%); }
.modal.xl { width: min(1100px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 16px 16px; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(6, 14, 34, .35); z-index: 90; animation: fadeIn .15s; }
.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(520px, 100vw); background: var(--bg-elevated); box-shadow: var(--shadow-lg); z-index: 91; display: flex; flex-direction: column; animation: slideIn .2s var(--ease); border-left: 1px solid var(--border); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: 12px; background: var(--navy-900); color: #fff; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: slideIn .2s var(--ease); font-size: 13.5px; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: var(--teal-400); }
.toast.error { background: #3B0D0D; }
.toast.error svg { color: #FCA5A5; }
.toast .tid { display: block; font-size: 11px; opacity: .6; font-family: var(--mono); margin-top: 2px; }
.menu { position: absolute; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 220px; z-index: 60; }
.menu button, .menu a { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; border: none; background: none; color: var(--text); font: 500 13.5px var(--font); cursor: pointer; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.menu svg { width: 16px; height: 16px; color: var(--text-3); }

/* ---------- États ---------- */
.empty { padding: 40px 20px; text-align: center; color: var(--text-3); }
.empty .ico { width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 14px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.empty .ico svg { width: 22px; height: 22px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 14px; }
.skeleton.block { height: 90px; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.notice { display: flex; gap: 10px; padding: 11px 14px; border-radius: 10px; background: var(--info-soft); color: var(--text-2); font-size: 13px; border: 1px solid color-mix(in srgb, var(--info) 20%, transparent); }
.notice svg { width: 18px; height: 18px; flex: none; color: var(--info); margin-top: 1px; }
.notice.warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.notice.warning svg { color: var(--warning); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice.danger svg { color: var(--danger); }
.notice.success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.notice.success svg { color: var(--success); }

/* ---------- Listes, timeline, kanban, calendrier ---------- */
.list-item { display: flex; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item::before { content: ""; position: absolute; left: -19px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.tl-item.accent::before { border-color: var(--accent); }
.tl-item.danger::before { border-color: var(--danger); }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px; min-height: 200px; display: flex; flex-direction: column; gap: 8px; }
.kcol.over { outline: 2px dashed var(--primary); outline-offset: -4px; }
.kcol-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 6px; font-weight: 700; font-size: 12.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: transform .1s, box-shadow .15s; }
.kcard:hover { box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; }
.kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-h { padding: 8px; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-d { min-height: 112px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); }
.cal-d.out { background: var(--surface-2); color: var(--text-3); }
.cal-d.today .dn { background: var(--primary); color: #fff; }
.dn { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; font-weight: 600; }
.ev { display: block; font-size: 11.5px; padding: 2px 6px; border-radius: 5px; margin-top: 3px; background: var(--primary-soft); color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; border: none; width: 100%; text-align: left; font-family: inherit; }
.ev.hearing { background: var(--danger-soft); color: var(--danger); }
.ev.deadline { background: var(--warning-soft); color: var(--warning); }
.ev.appointment { background: var(--accent-soft); color: var(--accent); }
.gantt { display: grid; grid-template-columns: 260px 1fr; }
.gantt-row { display: contents; }
.gantt-label { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.gantt-track { position: relative; border-bottom: 1px solid var(--border); min-height: 36px; }
.gantt-bar { position: absolute; top: 9px; height: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--electric-500), var(--teal-500)); }
.gantt-bar.done { background: var(--success); opacity: .6; }
.gantt-bar.late { background: var(--danger); }
.progress { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--electric-500), var(--teal-500)); }
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }
.steps { display: flex; gap: 0; counter-reset: step; }
.step { flex: 1; position: relative; padding-top: 34px; text-align: center; font-size: 12px; color: var(--text-3); }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); font-weight: 700; z-index: 1; }
.step::after { content: ""; position: absolute; top: 12px; left: -50%; right: 50%; height: 2px; background: var(--border); }
.step:first-child::after { display: none; }
.step.done::before { background: var(--success); color: #fff; content: "✓"; }
.step.current::before { background: var(--primary); color: #fff; }
.step.done, .step.current { color: var(--text); font-weight: 600; }

/* ---------- Graphiques ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-3); font: 11px var(--font); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 3; }
.chart .axis { stroke: var(--border-strong); }
.chart .donut-track { stroke: var(--surface-3); }
.chart text.donut-value { fill: var(--text); font-size: 22px; font-weight: 750; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bars .bar-row { display: grid; grid-template-columns: 160px 1fr 60px; gap: 10px; align-items: center; margin: 9px 0; font-size: 13px; }
.bars .track { height: 10px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 6px; }

/* ---------- IA ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 92%; padding: 12px 14px; border-radius: 14px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.ai h4 { font-size: 13px; margin: 10px 0 4px; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; }
.msg.ai p { margin: 0 0 6px; }
.cite { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); cursor: pointer; border: none; font-family: inherit; }
.cite.bad { background: var(--danger-soft); color: var(--danger); }
.ai-banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 12px; background: linear-gradient(120deg, var(--primary-soft), var(--accent-soft)); border: 1px solid var(--border); }
mark { background: color-mix(in srgb, var(--teal-400) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.diff-ins { background: var(--success-soft); color: var(--success); display: block; padding: 0 8px; white-space: pre-wrap; }
.diff-del { background: var(--danger-soft); color: var(--danger); display: block; padding: 0 8px; text-decoration: line-through; white-space: pre-wrap; }
.diff-eq { display: block; padding: 0 8px; color: var(--text-3); white-space: pre-wrap; }
.pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; max-height: 420px; overflow: auto; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: 10px; background: #fff; }

/* ---------- Authentification ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  background: radial-gradient(900px 500px at 10% 10%, rgba(45, 212, 191, .25), transparent 60%),
              radial-gradient(700px 500px at 90% 90%, rgba(59, 130, 246, .35), transparent 60%),
              linear-gradient(140deg, var(--navy-950), var(--navy-800));
  color: #E6EDFB; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art h1 { color: #fff; font-size: 38px; line-height: 1.12; max-width: 520px; letter-spacing: -.02em; }
.auth-art .feat { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; max-width: 460px; }
.auth-art .feat svg { width: 20px; height: 20px; color: var(--teal-400); flex: none; margin-top: 2px; }
.auth-form { display: grid; place-items: center; padding: 40px; background: var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }

/* ---------- Portail client ---------- */
.portal-top { background: var(--navy-900); color: #fff; padding: 0 24px; height: 64px; display: flex; align-items: center; gap: 14px; }
.portal-wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s var(--ease); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .icon-btn.menu-toggle { display: inline-grid; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .content { padding: 16px; }
  .user-chip .who { display: none; }
  .bars .bar-row { grid-template-columns: 110px 1fr 50px; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
  .global-search .kbd { display: none; }
  .page-head h1 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .actions, .toolbar { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
