/* =====================================================================
   ICT Manager — feuille de style
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #e8f0fe;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
  --radius: 14px;
  --radius-sm: 9px;

  --sb-bg: #0b1220;
  --sb-text: #a9b4c7;
  --sb-text-hi: #ffffff;
  --sb-hover: rgba(255, 255, 255, .06);
  --sb-active: rgba(59, 130, 246, .18);

  /* séries graphiques (statuts) — palette validée daltonisme */
  --s-plan: #6a4ce2;
  --s-wait: #f47230;
  --s-prog: #257de0;
  --s-done: #008a17;

  /* badges : fond teinté + texte foncé */
  --b-gray-bg: #eef2f6;  --b-gray-fg: #334155;
  --b-blue-bg: #e3edfd;  --b-blue-fg: #1d4ed8;
  --b-violet-bg: #ede9fe; --b-violet-fg: #5b21b6;
  --b-orange-bg: #ffedd5; --b-orange-fg: #9a3412;
  --b-yellow-bg: #fef3c7; --b-yellow-fg: #854d0e;
  --b-green-bg: #dcfce7;  --b-green-fg: #166534;
  --b-red-bg: #fee2e2;    --b-red-fg: #b91c1c;
  --b-crit-bg: #b91c1c;   --b-crit-fg: #ffffff;

  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b24;
  --surface-2: #1b212c;
  --surface-3: #222a36;
  --border: #2a3342;
  --text: #e8edf5;
  --text-2: #aab4c3;
  --text-3: #8592a6;
  --accent: #4b8df8;
  --accent-2: #6aa1fa;
  --accent-soft: rgba(75, 141, 248, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5);
  --sb-bg: #090d14;

  --s-plan: #9887ef;
  --s-wait: #e76624;
  --s-prog: #338ced;
  --s-done: #0aac23;

  --b-gray-bg: #273041;  --b-gray-fg: #cbd5e1;
  --b-blue-bg: rgba(59,130,246,.18);  --b-blue-fg: #93c5fd;
  --b-violet-bg: rgba(139,92,246,.2); --b-violet-fg: #c4b5fd;
  --b-orange-bg: rgba(249,115,22,.18); --b-orange-fg: #fdba74;
  --b-yellow-bg: rgba(234,179,8,.18); --b-yellow-fg: #fde047;
  --b-green-bg: rgba(34,197,94,.16);  --b-green-fg: #86efac;
  --b-red-bg: rgba(239,68,68,.18);    --b-red-fg: #fca5a5;
  --b-crit-bg: #dc2626;  --b-crit-fg: #ffffff;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h3 { font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { flex-shrink: 0; vertical-align: middle; }
.mt { margin-top: 18px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0; background: var(--sb-bg); color: var(--sb-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; color: var(--sb-text-hi); }
.brand:hover { color: var(--sb-text-hi); }
.brand-logo { color: #2563eb; display: inline-flex; }
.brand-name { font-weight: 700; font-size: 1.08rem; letter-spacing: -.01em; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: #64748b; padding: 18px 12px 6px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--sb-text); font-weight: 500; font-size: .93rem; position: relative;
}
.nav-link:hover { background: var(--sb-hover); color: var(--sb-text-hi); }
.nav-link.active { background: var(--sb-active); color: var(--sb-text-hi); }
.nav-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #3b82f6; }
.nav-count { margin-left: auto; background: #dc2626; color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.nav-lock { margin-left: auto; color: #f59e0b; display: inline-flex; }
.nav-count + .nav-lock { margin-left: 6px; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 14px 14px 18px; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-foot .icon-btn { color: var(--sb-text); }
.sidebar-foot .icon-btn:hover { background: var(--sb-hover); color: #fff; }
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--sb-text-hi); padding: 4px; border-radius: 10px; }
.me:hover { color: #fff; background: var(--sb-hover); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text strong { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--sb-text); font-size: .76rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #7c3aed); color: #fff; font-weight: 700; font-size: .85rem;
}
.avatar.sm { width: 32px; height: 32px; font-size: .8rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.page-title { font-size: 1.35rem; font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.today { display: inline-flex; gap: 6px; align-items: center; color: var(--text-3); font-size: .88rem; }
.content { padding: 26px 32px 48px; display: flex; flex-direction: column; gap: 22px; max-width: 1600px; width: 100%; }
.only-mobile { display: none !important; }
.content > * { min-width: 0; }

/* ---------------- Composants de base ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.link { font-size: .87rem; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.align-start { align-items: start; }
.section-title { font-size: 1.05rem; margin: 6px 0 -8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); color: #fff; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--b-red-bg); color: var(--danger); }
.btn-block { width: 100%; }
.btn.sm { padding: 5px 11px; font-size: .82rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 0; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn.danger:hover { background: var(--b-red-bg); color: var(--danger); }
:root:not([data-theme="dark"]) .i-sun, :root[data-theme="dark"] .i-moon { display: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--b-gray-bg); color: var(--b-gray-fg);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.b-soft::before, .b-role::before { display: none; }
.b-a-planifier { background: var(--b-violet-bg); color: var(--b-violet-fg); }
.b-en-attente, .b-en-suivi { background: var(--b-orange-bg); color: var(--b-orange-fg); }
.b-en-cours, .b-en-cours-de-resolution { background: var(--b-blue-bg); color: var(--b-blue-fg); }
.b-termine, .b-resolu { background: var(--b-green-bg); color: var(--b-green-fg); }
.b-ouvert { background: var(--b-red-bg); color: var(--b-red-fg); }
.b-cloture, .b-off { background: var(--b-gray-bg); color: var(--b-gray-fg); }
.b-faible, .b-basse { background: var(--b-green-bg); color: var(--b-green-fg); }
.b-moyen, .b-moyenne { background: var(--b-yellow-bg); color: var(--b-yellow-fg); }
.b-eleve, .b-haute { background: var(--b-orange-bg); color: var(--b-orange-fg); }
.b-critique { background: var(--b-crit-bg); color: var(--b-crit-fg); }
.b-role.b-admin { background: var(--b-red-bg); color: var(--b-red-fg); }
.b-role.b-supervisor { background: var(--b-violet-bg); color: var(--b-violet-fg); }
.b-role.b-user { background: var(--b-blue-bg); color: var(--b-blue-fg); }

/* Chips (intervenants colorés selon le référentiel) */
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 7px;
  font-size: .8rem; font-weight: 500; background: var(--surface-3); color: var(--text); border: 1px solid var(--border); white-space: nowrap;
}
.chip-color { background: color-mix(in srgb, var(--c) 13%, var(--surface)); border-color: color-mix(in srgb, var(--c) 45%, transparent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); font-style: normal; }
.swatch { display: inline-block; width: 28px; height: 28px; border-radius: 8px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

/* Progression */
.progress { display: inline-block; vertical-align: middle; width: 110px; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #3b82f6, #2563eb); }
.progress-label { font-size: .82rem; font-weight: 600; margin-left: 8px; font-variant-numeric: tabular-nums; }
.col-progress { min-width: 170px; }

/* Pills (hero) */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600; }
.pill-red { background: var(--b-red-bg); color: var(--b-red-fg); }
.pill-orange { background: var(--b-orange-bg); color: var(--b-orange-fg); }
.pill-green { background: var(--b-green-bg); color: var(--b-green-fg); }
.pill:hover { filter: brightness(.97); }

/* ---------------- Flash / alertes ---------------- */
.flashes { padding: 0 32px; display: flex; flex-direction: column; gap: 8px; }
.flashes:not(:empty) { padding-top: 18px; }
.flash, .alert { padding: 12px 16px; border-radius: 11px; font-size: .92rem; border: 1px solid transparent; }
.flash { display: flex; align-items: center; gap: 10px; animation: slidein .25s ease-out; }
.flash-x { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; display: inline-flex; }
.flash-success, .alert-success { background: var(--b-green-bg); color: var(--b-green-fg); border-color: color-mix(in srgb, var(--b-green-fg) 25%, transparent); }
.flash-error, .alert-error { background: var(--b-red-bg); color: var(--b-red-fg); border-color: color-mix(in srgb, var(--b-red-fg) 25%, transparent); }
.flash-warning, .alert-warning { background: var(--b-yellow-bg); color: var(--b-yellow-fg); border-color: color-mix(in srgb, var(--b-yellow-fg) 25%, transparent); }
.flash-info { background: var(--b-blue-bg); color: var(--b-blue-fg); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }
.confidential-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 12px;
  background: repeating-linear-gradient(135deg, var(--b-yellow-bg), var(--b-yellow-bg) 12px, color-mix(in srgb, var(--b-yellow-bg) 70%, var(--surface)) 12px, color-mix(in srgb, var(--b-yellow-bg) 70%, var(--surface)) 24px);
  color: var(--b-yellow-fg); border: 1px solid color-mix(in srgb, var(--b-yellow-fg) 30%, transparent); font-size: .9rem;
}

/* ---------------- Dashboard ---------------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 26px 30px;
  background: linear-gradient(120deg, #1e3a8a 0%, #2563eb 55%, #4f46e5 100%); color: #fff; border: 0; position: relative; overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; right: -80px; top: -120px; width: 380px; height: 380px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 70%); pointer-events: none;
}
.eyebrow { margin: 0 0 4px; opacity: .8; font-weight: 500; }
.hero-title { font-size: 1.55rem; font-weight: 700; margin-bottom: 14px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.hero .pill { background: rgba(255,255,255,.15); color: #fff; backdrop-filter: blur(4px); }
.hero .pill:hover { background: rgba(255,255,255,.25); }
.hero-ring { display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 1; }
.hero-ring small { color: rgba(255,255,255,.8); }
.ring {
  --size: 104px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.2) 0);
}
.ring span { width: calc(var(--size) - 18px); height: calc(var(--size) - 18px); border-radius: 50%; background: #2350d6; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; }
.ring span { display: flex; align-items: center; justify-content: center; }
.ring small { font-size: .9rem; margin-left: 1px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  display: grid; grid-template-columns: auto 1fr; grid-template-areas: "icon value" "label label"; align-items: center; gap: 10px 12px;
  color: var(--text); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--k); opacity: .9; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--text); }
.kpi-icon { grid-area: icon; width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--k) 14%, var(--surface)); color: var(--k); }
.kpi-value { grid-area: value; font-size: 1.9rem; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-label { grid-area: label; font-size: .86rem; color: var(--text-2); font-weight: 500; }
.t-blue { --k: #2563eb; } .t-slate { --k: #475569; } .t-prog { --k: var(--s-prog); }
.t-wait { --k: var(--s-wait); } .t-plan { --k: var(--s-plan); } .t-done { --k: var(--s-done); }
:root[data-theme="dark"] .t-slate { --k: #94a3b8; }

.chart-wrap { position: relative; height: 280px; }
.chart-donut { height: 250px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; padding: 0; margin: 14px 0 0; font-size: .86rem; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend strong { color: var(--text); }
.lg { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.lg-a-planifier { background: var(--s-plan); } .lg-en-attente { background: var(--s-wait); }
.lg-en-cours { background: var(--s-prog); } .lg-termine { background: var(--s-done); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; background: none; border: 0; font: inherit; font-weight: 600; font-size: .9rem;
  color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { background: var(--surface-3); color: var(--text-2); border-radius: 99px; padding: 0 8px; font-size: .76rem; }
.tab.active .tab-count { background: var(--accent-soft); color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }

.stack-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.stack-list li + li { border-top: 1px solid var(--border); }
.stack-list a, .sl-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; color: var(--text); border-radius: 8px; }
.stack-list a:hover { background: var(--surface-2); color: var(--text); }
.sl-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sl-main strong { font-size: .9rem; font-weight: 600; }
.sl-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.date-chip { font-size: .8rem; font-weight: 600; padding: 2px 9px; border-radius: 7px; background: var(--surface-3); }
.date-chip.late { background: var(--b-red-bg); color: var(--b-red-fg); }
.empty { padding: 12px 0; margin: 0; }

/* Mini stats & incidents */
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.mini-v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.mini-l { color: var(--text-2); font-size: .85rem; }
.mini-alert .mini-v { color: var(--danger); }

.sev-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.sev-card {
  border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--sc); box-shadow: var(--shadow);
}
.sev-card:hover { color: var(--text); box-shadow: var(--shadow-lg); }
.sev-label { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .86rem; color: var(--sc); }
.sev-v { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sev-card small { color: var(--text-3); }
.sev-critique { --sc: #dc2626; } .sev-haute { --sc: #ea580c; } .sev-moyenne { --sc: #ca8a04; } .sev-faible { --sc: #16a34a; } .sev-info { --sc: var(--accent); }

.dep-bars { display: flex; flex-direction: column; gap: 8px; }
.dep-row { display: grid; grid-template-columns: 180px 1fr 30px; align-items: center; gap: 10px; font-size: .88rem; }
.dep-bar { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.dep-bar i { display: block; height: 100%; background: var(--c); border-radius: 99px; }

/* Périmètres */
.perimeter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.perimeter header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.perimeter h3 { font-size: 1.02rem; }
.perimeter .chip { white-space: normal; }

/* Rôles */
.roles-info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.role-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.role-card p { margin: 8px 0 0; font-size: .86rem; color: var(--text-2); }
.user-cell { display: flex; align-items: center; gap: 10px; }
.temp-pw { display: flex; flex-direction: column; gap: 8px; }
.pw { font-size: 1.15rem; font-weight: 700; padding: 8px 14px; background: var(--surface); color: var(--text); border-radius: 8px; width: fit-content; cursor: copy; letter-spacing: .04em; }

/* ---------------- Tableaux ---------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar.plain { margin-bottom: -6px; }
.toolbar p { margin: 0; }
.toolbar-spacer { flex: 1; }
.toolbar select, .search input { height: 38px; }
.search { position: relative; display: flex; align-items: center; min-width: 240px; flex: 0 1 320px; }
.search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 34px !important; width: 100%; }
.result-count { margin: 14px 0 6px; font-size: .85rem; }

.table-wrap { position: relative; overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3);
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table.compact td { padding: 8px 12px; }
.th-sort { color: inherit; }
.th-sort:hover, .th-sort.sorted { color: var(--accent); }
tr.clickable { cursor: pointer; }
tr.row-late td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.row-muted td { opacity: .55; }
.c-text, .c-strong { min-width: 150px; }
.c-people { min-width: 130px; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-actions form { display: inline; }
.truncate { display: inline-block; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; color: var(--text-2); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.empty-state { text-align: center; padding: 36px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---------------- Formulaires ---------------- */
input[type=text], input[type=password], input[type=email], input[type=search], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  font: inherit; font-size: .93rem; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
select { padding-right: 30px; }
.toolbar select { width: auto; max-width: 220px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { background: var(--surface-3); color: var(--text-3); }
textarea { resize: vertical; min-height: 96px; }
.form-page { max-width: 980px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.back-link { font-weight: 600; font-size: .9rem; width: fit-content; }
.form-card { padding: 24px 26px; }
.form-card.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > span { font-weight: 600; font-size: .86rem; color: var(--text-2); }
.field.wide { grid-column: 1 / -1; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.req { color: var(--danger); }
.help { color: var(--text-3); font-size: .8rem; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.check { display: flex; gap: 10px; align-items: center; font-size: .9rem; cursor: pointer; grid-column: 1 / -1; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input { flex: 1; accent-color: var(--accent); }
.range-row output { font-weight: 700; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.color-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
input[type=color] { width: 54px; height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; }
.color-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.preset { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--surface); background: var(--c); cursor: pointer; box-shadow: 0 0 0 1px var(--border); }
.preset:hover { transform: scale(1.12); }
.input-group { display: flex; gap: 8px; }
.strength { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.strength i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border: 1px dashed color-mix(in srgb, var(--danger) 40%, transparent); border-radius: var(--radius); }

/* ---------------- Auth ---------------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a8a 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #4f46e5 0%, transparent 55%), #0b1220;
}
.auth-wrap { width: 100%; max-width: 410px; display: flex; flex-direction: column; gap: 12px; }
.auth-card { background: var(--surface); border-radius: 20px; padding: 34px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-logo { margin-bottom: 10px; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-brand p { margin: 4px 0 0; }
.auth-card .alert { margin-bottom: 16px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sev-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s ease; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop { display: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .flashes { padding-left: 18px; padding-right: 18px; }
  .grid-2, .grid-3, .form-grid, .roles-info { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 640px) {
  .kpis, .sev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { flex: 1 1 100%; }
  .toolbar select { flex: 1 1 45%; max-width: none; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .table td { border: 0; padding: 4px 0; display: flex; gap: 10px; }
  .table td[data-label]::before { content: attr(data-label); min-width: 110px; color: var(--text-3); font-size: .78rem; font-weight: 600; text-transform: uppercase; }
  .col-actions { text-align: left; }
  .dep-row { grid-template-columns: 120px 1fr 24px; }
}
@media print {
  .sidebar, .topbar, .toolbar, .col-actions, .flashes { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
