:root {
  --brand: #6d28d9;
  --brand-clair: #a78bfa;
  --nav-bg: #3b0764;
  --page-bg: #f6f3fc;
  --surface: #ffffff;
  --border: #e0d9ee;
  --text: #1f1830;
  --muted: #6b6485;
  --alerte: #c2410c;
}

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

:root { --sb-large: 240px; --sb-etroit: 64px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sb-large);
  background: var(--nav-bg);
  color: #e9defa;
  display: flex;
  flex-direction: column;
  padding: .75rem .6rem;
  gap: .5rem;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1030;
  transition: width .2s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .7rem 1rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-brand i { font-size: 1.35rem; color: var(--brand-clair); }
.sidebar-nouveau { display: flex; align-items: center; justify-content: center; gap: .5rem; white-space: nowrap; margin-bottom: .4rem; }
.sidebar-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.sidebar-lien {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .55rem .7rem;
  border: 0;
  border-radius: .5rem;
  background: transparent;
  color: #e9defa;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  font-size: .95rem;
}
.sidebar-lien i { font-size: 1.15rem; width: 1.3rem; text-align: center; flex: none; }
.sidebar-lien:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.sidebar-lien.active { background: rgba(167, 139, 250, .25); color: #fff; box-shadow: inset 3px 0 0 var(--brand-clair); }
.sidebar-pied { margin-top: auto; display: flex; flex-direction: column; gap: .15rem; border-top: 1px solid rgba(255, 255, 255, .15); padding-top: .6rem; }
.sidebar-utilisateur { display: flex; align-items: center; gap: .75rem; padding: .4rem .7rem; font-size: .85rem; white-space: nowrap; }
.sidebar-utilisateur i { font-size: 1.15rem; width: 1.3rem; text-align: center; flex: none; }
.sidebar-utilisateur small { font-size: .72rem; }

.contenu-principal { margin-left: var(--sb-large); transition: margin-left .2s ease; min-width: 0; }
body.sans-sidebar .contenu-principal { margin-left: 0; }

html.sb-replie .sidebar { width: var(--sb-etroit); }
html.sb-replie .contenu-principal { margin-left: var(--sb-etroit); }
html.sb-replie body.sans-sidebar .contenu-principal { margin-left: 0; }
html.sb-replie .sidebar-texte { display: none; }
html.sb-replie .sidebar-lien,
html.sb-replie .sidebar-brand,
html.sb-replie .sidebar-utilisateur,
html.sb-replie .sidebar-nouveau { justify-content: center; padding-left: 0; padding-right: 0; }
html.sb-replie #sidebarBascule i { transform: rotate(180deg); }

@media (prefers-reduced-motion: reduce) {
  .sidebar, .contenu-principal { transition: none; }
}

.btn-promethee { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-promethee:hover { background: #5b21b6; border-color: #5b21b6; color: #fff; }

.carte-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.section-cours { border-left: 4px solid var(--brand); }
.section-prendre { border-left: 4px solid var(--alerte); }
.titre-section { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .6rem;
  min-width: 84px;
  padding: .4rem .7rem;
}
.kpi-valeur { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.kpi-libelle { font-size: .72rem; color: var(--muted); }
.kpi-alerte { border-color: var(--alerte); }
.kpi-alerte .kpi-valeur { color: var(--alerte); }
.kpi-urgent { border-color: #dc2626; background: #fef2f2; }
.kpi-urgent .kpi-valeur { color: #dc2626; }

.table-ot th { font-size: .75rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
.table-ot td { font-size: .86rem; }
.cellule-objet { max-width: 260px; }
.ligne-retard { background: #fff7ed; }
.badge-type { background: #ede9fe; color: #4c1d95; font-weight: 600; }

.tuile-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: 1.1rem .5rem;
  border: 1px solid var(--border);
  border-radius: .6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: border-color .15s, background .15s;
}
.tuile-type i { font-size: 1.7rem; color: var(--brand); }
.tuile-type:hover { border-color: var(--brand); background: #f5f0ff; color: var(--text); }

.chrono { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chrono-actif { color: var(--brand); }
.texte-multiligne { white-space: pre-wrap; }
.historique li { padding: .25rem 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.historique li:last-child { border-bottom: 0; }

.champ-code { -webkit-text-security: disc; font-family: monospace; letter-spacing: .15em; }

.page-login { display: flex; align-items: center; justify-content: flex-start; min-height: 100vh; margin: 0; background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%); padding-left: clamp(24px, 8vw, 120px); }
.login-bg { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center; }
.login-wrapper { width: 100%; max-width: 380px; padding: 16px; }
@media (max-width: 768px) { .page-login { justify-content: center; padding-left: 0; } }
.login-carte { width: 100%; border: none; border-radius: 12px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); }

.kpi-temps { border-color: var(--brand-clair); }
.kpi-temps .kpi-valeur { color: var(--brand); }

.metriques-grille { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
.metrique { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: .5rem; background: #faf8ff; }
.metrique-icone { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex: none; }
.metrique-valeur { font-weight: 700; font-size: 1rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metrique-detail { font-weight: 500; font-size: .75rem; color: var(--muted); }
.metrique-libelle { font-size: .72rem; color: var(--muted); }
.m-travail { background: #ede9fe; color: #6d28d9; }
.m-pause { background: #fef3c7; color: #b45309; }
.m-attente { background: #ffedd5; color: #c2410c; }
.m-sessions { background: #e5e7eb; color: #4b5563; }
.m-prise { background: #dbeafe; color: #1d4ed8; }
.m-age { background: #f3e8ff; color: #7e22ce; }

.table-planning { table-layout: fixed; min-width: 900px; }
.table-planning th { font-size: .78rem; text-align: center; vertical-align: middle; background: #faf8ff; }
.table-planning .colonne-ligne { width: 130px; text-align: left; }
.cellule-planning { min-height: 84px; height: 84px; vertical-align: top; padding: .25rem !important; background: #fff; }
.cellule-planning.survol { background: #f5f0ff; outline: 2px dashed var(--brand-clair); outline-offset: -2px; }
.cellule-planning.surcharge { background: #fef2f2; }
.jour-aujourdhui { box-shadow: inset 0 3px 0 var(--brand); }
.carte-ot { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: .4rem; background: #fff; padding: .25rem .4rem; margin-bottom: .25rem; font-size: .78rem; cursor: grab; }
.carte-ot.prio-urgent { border-left-color: #dc2626; }
.carte-ot.prio-normal { border-left-color: var(--brand-clair); }
.carte-ot.prio-faible { border-left-color: #9ca3af; }
.carte-ot-fixe { cursor: default; background: #faf8ff; }
.carte-ot-fantome { border-style: dashed; color: var(--muted); cursor: default; background: transparent; }
.carte-ot-objet { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.charge { text-align: right; color: var(--muted); }

.galerie { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .75rem; }
.galerie-photo { margin: 0; width: 150px; }
.galerie-photo img { width: 150px; height: 112px; object-fit: cover; border-radius: .4rem; border: 1px solid var(--border); }
.commentaire { border-left: 3px solid var(--border); padding: .2rem .6rem; margin-bottom: .5rem; }
.commentaire-moi { border-left-color: var(--brand-clair); background: #faf8ff; }
