:root {
  --primary: #2c5f8a;
  --primary-dark: #1d3f5c;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #d8dee6;
  --text: #2a2f36;
  --muted: #6b7785;
  --accent: #e8a93b;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

header.topbar {
  background: var(--primary-dark);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

header.topbar h1 {
  margin: 0;
  font-size: 1.3em;
}

header.topbar nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 16px;
  font-size: 0.95em;
  opacity: 0.9;
}

header.topbar nav a:hover { opacity: 1; text-decoration: underline; }

.container {
  max-width: 1000px;
  margin: 24px auto;
  padding: 0 16px 60px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card h2 {
  margin-top: 0;
  font-size: 1.15em;
  color: var(--primary-dark);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.menu-item {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

.menu-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.menu-item.is-hidden {
  display: none;
}

.menu-item .tag {
  display: inline-block;
  font-size: 0.75em;
  background: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  margin-bottom: 8px;
}

.menu-item h3 { margin: 4px 0 6px; font-size: 1.05em; }
.menu-item p { margin: 0; color: var(--muted); font-size: 0.9em; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.form-grid.full { grid-template-columns: 1fr; }

label {
  display: block;
  font-size: 0.85em;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.95em;
  font-family: inherit;
  background: #fff;
}

textarea { resize: vertical; }

.field { margin-bottom: 10px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 14px;
  padding: 12px 14px;
}

legend {
  font-weight: 600;
  color: var(--primary-dark);
  padding: 0 6px;
}

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 5px;
  font-size: 0.92em;
  cursor: pointer;
  text-decoration: none;
  margin: 4px 4px 4px 0;
}

button:hover, .btn:hover { background: var(--primary-dark); }

button.secondary, .btn.secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

button.secondary:hover, .btn.secondary:hover { background: #eef4fa; }

button.danger { background: #b3413a; }
button.danger:hover { background: #8e2f29; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}

th, td {
  border: 1px solid var(--border);
  padding: 7px 9px;
  text-align: left;
}

th { background: #eef2f6; }

.preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 30px 40px;
  font-family: "Liberation Serif", Georgia, serif;
  line-height: 1.5;
  white-space: pre-wrap;
  max-width: 800px;
  margin: 0 auto;
}

.preview h2, .preview h3 { text-align: center; }

.note {
  font-size: 0.85em;
  color: var(--muted);
  margin-top: 6px;
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: #4a3000;
  font-size: 0.75em;
  border-radius: 10px;
  padding: 2px 8px;
  margin-left: 6px;
}
.badge.green { background: #22c55e; color: #06280f; }
.badge.orange { background: #f59e0b; color: #3a2400; }
.badge.red { background: #ef4444; color: #fff; }
.badge.yellow { background: #eab308; color: #3a2c00; }
.badge.blue { background: #3b82f6; color: #fff; }

@media print {
  header.topbar, .no-print { display: none !important; }
  .container { margin: 0; padding: 0; }
  .preview { border: none; padding: 0; }
}

#userbar {
  font-size: 0.85em;
  color: #fff;
  opacity: 0.9;
}
#userbar a { color: #fff; text-decoration: underline; }

/* Tri des tableaux au clic sur l'entete */
table.js-sortable th { cursor: pointer; user-select: none; position: relative; }
table.js-sortable th:hover { background: #e3e9ef; }
table.js-sortable th.sorted-asc::after { content: " \25B2"; font-size: 0.8em; }
table.js-sortable th.sorted-desc::after { content: " \25BC"; font-size: 0.8em; }

.notif-badge {
  background: #e02424;
  color: #fff !important;
  border-radius: 10px;
  padding: 2px 8px;
  font-weight: 700;
  text-decoration: none !important;
}
.notif-badge:hover { background: #b91c1c; }

.cmdk-trigger {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 0.85em;
  cursor: pointer;
}
.cmdk-trigger:hover { background: rgba(255,255,255,0.15); }
.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.cmdk-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cmdk-box input {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  font-size: 1em;
  outline: none;
  border-radius: 0;
}
.cmdk-results { overflow-y: auto; padding: 6px; }
.cmdk-item {
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92em;
}
.cmdk-item .cmdk-tag { font-size: 0.75em; color: var(--muted); }
.cmdk-item.active, .cmdk-item:hover { background: #eef4fa; }
.cmdk-empty { padding: 12px; color: var(--muted); font-size: 0.9em; text-align: center; }

.menu-group-title {
  margin: 26px 0 12px;
  font-size: 1.05em;
  color: var(--primary-dark);
  font-weight: 700;
}
.menu-group-title:first-of-type { margin-top: 0; }

/* -----------------------------------------------------------
   LANCEUR (page d'accueil) — style "menu d'applications"
   ----------------------------------------------------------- */

.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;
}

.launcher {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  padding: 0;
}

.launcher-rail {
  width: 56px;
  flex: none;
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
}

.rail-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15em;
  text-decoration: none;
  color: #fff;
  transition: background .15s, transform .15s;
}

.rail-btn:hover { background: var(--primary); transform: translateY(-1px); }

.launcher-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.launcher-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.launcher-search-icon { color: var(--muted); }

.launcher-search input { flex: 1; }

.launcher-body {
  display: flex;
  min-height: 420px;
  max-height: 62vh;
}

.launcher-categories {
  width: 230px;
  flex: none;
  border-right: 1px solid var(--border);
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fafbfc;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 0.92em;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.cat-btn:hover { background: #eef2f6; }
.cat-btn.active { background: var(--primary); color: #fff; }

.launcher-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.launcher-group-title {
  margin: 18px 0 8px;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}

.menu-group:first-child .launcher-group-title { margin-top: 0; }

.menu-group.is-cat-hidden { display: none; }

.launcher-list .menu-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 2px;
}

.launcher-list .menu-item:hover { background: #eef4fa; border-color: var(--border); }
.launcher-list .menu-item.is-hidden { display: none; }

.mi-icon {
  font-size: 1.3em;
  line-height: 1.4;
  flex: none;
  width: 26px;
  text-align: center;
}

.mi-text { display: block; }
.mi-text .tag { margin-bottom: 4px; }
.mi-text h3 { margin: 2px 0 3px; font-size: 0.98em; }
.mi-text p { margin: 0; color: var(--muted); font-size: 0.85em; }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .launcher { flex-direction: column; }
  .launcher-rail {
    width: 100%;
    flex-direction: row;
    justify-content: center;
    padding: 8px;
  }
  .launcher-body { flex-direction: column; max-height: none; }
  .launcher-categories {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}


/* -----------------------------------------------------------
   LANCEUR — bandeau titre/utilisateur (remplace l'ancienne barre du haut)
   ----------------------------------------------------------- */

.launcher-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.launcher-topline h2 {
  margin: 0;
  font-size: 1.15em;
  color: var(--primary-dark);
  border: none;
  padding: 0;
}

.launcher-userinfo {
  font-size: 0.9em;
  color: var(--muted);
  white-space: nowrap;
}

.rail-item { position: relative; display: flex; }

.rail-notif-slot {
  position: absolute;
  top: -4px;
  right: -4px;
  line-height: 1;
}

.rail-notif-slot .notif-badge {
  padding: 1px 5px;
  font-size: 0.65em;
  border-radius: 8px;
  display: inline-block;
}

button.rail-btn {
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.rail-btn-logout { margin-top: auto; }


/* -----------------------------------------------------------
   Barre du haut minimale (pages autres que l'accueil) :
   juste "INCONNECT" en haut à gauche, retour à l'index.
   ----------------------------------------------------------- */

.topbar-logo {
  color: #fff;
  text-decoration: none;
  font-size: 1.2em;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.topbar-logo:hover { opacity: 0.85; text-decoration: none; }

/* -----------------------------------------------------------
   TABLEAU DE BORD (page d'accueil) : compteurs + activité récente
   ----------------------------------------------------------- */

.dashboard-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 4px;
}

.stat-tile {
  flex: 1 1 160px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
}

a.stat-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}

a.stat-tile:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.stat-value {
  font-size: 1.8em;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8em;
  color: var(--muted);
  margin-top: 4px;
}

.dashboard-quicklinks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 4px;
}

.dashboard-quicklinks a.secondary {
  display: inline-block;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
}

.activity-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.activity-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
}

.activity-item:last-child { border-bottom: none; }

.activity-type {
  font-weight: 600;
  color: var(--primary-dark);
}

.activity-meta {
  color: var(--text);
}

.activity-date {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85em;
  white-space: nowrap;
}



