:root {
  --navy: #1A2A6C;
  --navy-dark: #131f50;
  --red: #D81E1E;
  --red-dark: #b01616;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e2e5f0;
  --text: #20242e;
  --text-muted: #6b7080;
  --green: #1d9e75;
  --amber: #ba7517;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(26, 42, 108, 0.06), 0 1px 2px rgba(26, 42, 108, 0.04);
  --sidebar-w: 244px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", Roboto, Helvetica, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #cdd3ee;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
}
.sidebar .brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-align: center;
}
.sidebar .brand img { width: 130px; background: #fff; padding: 8px; border-radius: 8px; }
.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  color: #cdd3ee; padding: 10px 13px; border-radius: 8px;
  font-size: 14.5px; margin-bottom: 2px; text-decoration: none;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: var(--red); color: #fff; }
.sidebar nav a .ic { width: 18px; text-align: center; opacity: .9; }
.sidebar .foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; color: #9aa2cf; font-style: italic; }

.content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 20px; color: var(--navy); font-weight: 600; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}
.user-chip .meta { text-align: right; line-height: 1.2; }
.user-chip .meta .role { font-size: 12px; color: var(--text-muted); }

.main { padding: 26px 28px; max-width: 1180px; width: 100%; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-2 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 900px){ .grid.cols-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card h2 { font-size: 15px; color: var(--navy); margin-bottom: 14px; font-weight: 600; }
.card.stat { padding: 18px 20px; }
.card.stat .num { font-size: 30px; font-weight: 700; color: var(--navy); }
.card.stat .lbl { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.card.stat .ic { float: right; font-size: 22px; opacity: .25; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12.5px;
     text-transform: uppercase; letter-spacing: .02em; padding: 9px 10px; border-bottom: 2px solid var(--border); }
td { padding: 11px 10px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.j { background: #e6f1fb; color: #185fa5; }
.badge.h { background: #e1f5ee; color: #0f6e56; }
.badge.m { background: #faeeda; color: #854f0b; }
.badge.role { background: #eeedfe; color: #3c3489; }
.badge.gray { background: #f1efe8; color: #5f5e5a; }
.badge.red { background: #fceaea; color: var(--red-dark); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 8px;
       font-size: 14px; font-weight: 600; border: none; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-dark); text-decoration: none; }
.btn.red { background: var(--red); color: #fff; }
.btn.red:hover { background: var(--red-dark); text-decoration: none; }
.btn.ghost { background: #eef0f8; color: var(--navy); }
.btn.sm { padding: 6px 12px; font-size: 13px; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: #3a3f4d; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(26,42,108,.1);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 700px){ .form-grid { grid-template-columns: 1fr; } }
.hint { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash.success { background: #e9f7f1; color: #0f6e56; border-color: #b6e3d3; }
.flash.danger  { background: #fdeaea; color: #a32d2d; border-color: #f3c4c4; }
.flash.warning { background: #fdf3e2; color: #854f0b; border-color: #f3dcb0; }
.flash.info    { background: #e9f1fb; color: #185fa5; border-color: #c2d9f3; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; color: var(--navy); font-weight: 600; }
.subtle { color: var(--text-muted); font-size: 13.5px; }
.empty { text-align: center; color: var(--text-muted); padding: 30px; font-size: 14px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters a { padding: 7px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--border);
             font-size: 13.5px; color: var(--text); }
.filters a.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filters a:hover { text-decoration: none; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 38px 34px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); text-align: center; }
.login-card img { width: 180px; margin-bottom: 8px; }
.login-card .sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; }
.login-card .form-row { text-align: left; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-demo { margin-top: 18px; font-size: 12.5px; color: var(--text-muted); background: #f4f5f9;
  border-radius: 8px; padding: 10px 12px; }

/* ---------- Calendar ---------- */
.cal { width: 100%; border-collapse: collapse; }
.cal th { text-align: center; padding: 8px; }
.cal td { height: 86px; vertical-align: top; border: 1px solid var(--border); padding: 6px; width: 14.28%; }
.cal td.out { background: #fafbfd; }
.cal td.today { background: #eef2fe; }
.cal .daynum { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.cal td.ferie { background: #fceaea; }
.cal td.ferie .daynum { color: var(--red-dark); }
.cal .pill { display: block; font-size: 11px; padding: 2px 6px; border-radius: 5px; margin-top: 4px;
  background: #e6f1fb; color: #185fa5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .pill.ferie { background: #fceaea; color: var(--red-dark); }
.cal .pill.reunion { background: #eeedfe; color: #3c3489; }

/* ---------- Messagerie ---------- */
.chat { display: grid; grid-template-columns: 230px 1fr; gap: 0; height: calc(100vh - 150px);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat .canaux { border-right: 1px solid var(--border); overflow-y: auto; background: #fafbfd; }
.chat .canaux a { display: block; padding: 12px 14px; color: var(--text); font-size: 14px;
  border-bottom: 1px solid var(--border); }
.chat .canaux a:hover { background: #eef0f8; text-decoration: none; }
.chat .canaux a.active { background: var(--navy); color: #fff; }
.chat .panel { display: flex; flex-direction: column; }
.chat .panel .head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--navy); }
.chat .msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg .who { font-size: 13px; font-weight: 600; color: var(--navy); }
.msg .when { font-size: 11.5px; color: var(--text-muted); margin-left: 8px; }
.msg .body { font-size: 14px; margin-top: 2px; }
.chat .compose { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); }
.chat .compose input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }

/* ---------- Médias messagerie ---------- */
.msg-media { max-width: 320px; max-height: 240px; border-radius: 8px; margin-top: 6px; display: block; }
.msg-file { display: inline-block; margin-top: 6px; padding: 8px 12px; background: #eef0f8;
  border-radius: 8px; font-size: 13.5px; }
.chat .compose .attach-btn { display: grid; place-items: center; width: 40px; cursor: pointer;
  font-size: 18px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.chat .compose .attach-btn.has-file { background: #e1f5ee; border-color: #b6e3d3; }

/* ---------- Cloche notifications ---------- */
.bell { position: relative; font-size: 18px; text-decoration: none; padding: 4px; }
.bell:hover { text-decoration: none; }
.bell-badge { position: absolute; top: -4px; right: -6px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px; }

/* ---------- Responsive / mobile ---------- */
.hamburger { display: none; background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--navy); line-height: 1; padding: 4px 6px; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; }
.overlay.show { display: block; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; z-index: 100; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 30px rgba(0,0,0,.3); }
  .content { margin-left: 0; }
  .hamburger { display: block; }
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 17px; }
  .user-chip .meta { display: none; }          /* gagner de la place */
  .user-chip { gap: 8px; }
  .main { padding: 16px 14px; }
  .card { overflow-x: auto; }                   /* les tableaux larges défilent dans la carte */
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.stats { grid-template-columns: repeat(2, 1fr); }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .kanban { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat .canaux { max-height: 150px; }
  .chat .msgs { max-height: 50vh; }
  .login-card { padding: 28px 22px; }
}

@media (max-width: 420px) {
  .grid.stats { grid-template-columns: 1fr; }
}

/* ---------- Couleurs : repères visuels ---------- */
/* Rôle de l'auteur en messagerie (différencie DG, DG Adjoint, etc.) */
.msg .who-role { font-size: 11px; color: var(--navy); background: #eeedfe;
  border-radius: 10px; padding: 1px 7px; margin-left: 7px; font-weight: 600; }

/* En-têtes de section : barre colorée à gauche */
.card h2 { border-left: 3px solid var(--navy); padding-left: 9px; }

/* Barre colorée sous le titre de page */
.page-head h1 { border-left: 4px solid var(--red); padding-left: 10px; }

/* Cartes de statistiques : une couleur par carte pour distinguer d'un coup d'œil */
.grid.stats .card.stat { border-top: 3px solid var(--navy); }
.grid.stats .card.stat:nth-child(1) { border-top-color: #1A2A6C; }
.grid.stats .card.stat:nth-child(1) .ic { color: #1A2A6C; opacity: .5; }
.grid.stats .card.stat:nth-child(2) { border-top-color: #1d9e75; }
.grid.stats .card.stat:nth-child(2) .ic { color: #1d9e75; opacity: .5; }
.grid.stats .card.stat:nth-child(3) { border-top-color: #d98c0b; }
.grid.stats .card.stat:nth-child(3) .ic { color: #d98c0b; opacity: .5; }
.grid.stats .card.stat:nth-child(4) { border-top-color: #6b46c1; }
.grid.stats .card.stat:nth-child(4) .ic { color: #6b46c1; opacity: .5; }
.grid.stats .card.stat:nth-child(5) { border-top-color: #0e7490; }
.grid.stats .card.stat:nth-child(6) { border-top-color: #D81E1E; }

/* Onglets de filtre actifs plus visibles */
.filters a.active { background: var(--navy); color: #fff; }

/* Liens de navigation : pastille colorée discrète sur l'icône active */
.sidebar nav a.active { border-left: 3px solid var(--red); }
