:root {
  --green: #2f7d4f;
  --green-dark: #1f5c38;
  --bg: #f4f6f5;
  --card: #ffffff;
  --border: #dde3e0;
  --text: #22292a;
  --muted: #667070;
  --orange: #b5680c;
  --red: #b23b3b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ---- Left sidebar layout ---- */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--green-dark), #163f28);
  color: white;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 0 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 16px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
  text-decoration: none;
  color: white;
}
.sidebar-logo { height: 34px; width: auto; background: white; border-radius: 6px; padding: 3px; flex-shrink: 0; }
.sidebar-brand span { display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-brand strong { font-size: 0.95rem; }
.sidebar-brand em { font-style: normal; font-size: 0.72rem; opacity: 0.7; }

.notif-wrap { position: relative; padding: 0 12px 10px; }
.notif-bell-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 7px;
  color: #dcebe1;
  font-size: 0.86rem;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}
.notif-bell-btn:hover { background: rgba(255,255,255,0.14); color: white; }
.notif-bell-icon { font-size: 1rem; }
.notif-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 12px;
  right: 12px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 120;
  max-height: 60vh;
  overflow-y: auto;
}
.notif-dropdown.open { display: block; }
.notif-empty { color: var(--muted); font-size: 0.85rem; padding: 14px; margin: 0; }
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; }
.notif-item-action { color: var(--orange); font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.notif-item-code { color: var(--muted); }
.notif-item-label { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 12px;
  flex: 1;
}
.sidebar-nav a {
  color: #dcebe1;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 10px 12px;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-nav a.active { background: var(--green); color: white; font-weight: 600; }
.sidebar-nav a.sidebar-admin-link { margin-top: 8px; border-top: 1px solid rgba(255,255,255,0.14); padding-top: 12px; }

.sidebar-footer {
  padding: 14px 12px 16px;
  margin-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.14);
  font-size: 0.82rem;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 14px;
}
.sidebar-user-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-user-name { font-weight: 700; color: white; line-height: 1.3; }
.sidebar-user-meta { color: #b9d6c5; font-size: 0.78rem; }
.sidebar-footer-menu { display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer-item-form { margin: 0; }
.sidebar-footer-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #dcebe1;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-footer-item:hover { background: rgba(255,255,255,0.08); color: white; }
.sidebar-footer-item-danger { color: #e0b8b0; }
.sidebar-footer-item-danger:hover { background: rgba(224,120,96,0.16); color: #ffd9cc; }
.lang-switch {
  display: flex;
  margin-top: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 7px;
  padding: 3px;
  gap: 2px;
}
.lang-switch a {
  flex: 1;
  text-align: center;
  color: #9fc4ac;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 0;
  border-radius: 5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-switch a.active { background: rgba(255,255,255,0.18); color: white; }
.lang-switch a:hover:not(.active) { color: white; }
.lang-switch-login { text-align: center; margin-top: 14px; font-size: 0.85rem; }
.lang-switch-login a { color: var(--muted); text-decoration: none; }
.lang-switch-login a.active { color: var(--green-dark); font-weight: 700; text-decoration: underline; }
.lang-switch-login span { color: var(--border); margin: 0 6px; }

.sidebar-toggle {
  display: none;
  position: relative;
  background: var(--green-dark);
  color: white;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.notif-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.sidebar-overlay { display: none; }

.app-main { flex: 1; min-width: 0; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
/* A page of wide tables (header.ejs `wide: true`): the content uses the whole width left by the menu instead of the 1100 px column. */
.container.container-wide { max-width: none; padding-left: 16px; padding-right: 16px; }
/* The spending reports (Suivi des dépenses, Mes codes budget, détail d'un code budget): ten-column tables that must fit the page WITHOUT a
   horizontal scroll at the usual laptop width (1366 px minus the 250 px menu). The sort links of the headers may wrap (a long header such as
   "Dépense totale réceptionnée" used to stretch its column to 200 px), the cells are a little tighter and an amount never breaks inside its
   digits (the thousands separator of the locale is a no-break space), only its unit or its count goes to the next line. The card keeps its
   own scroll as a safety net for a really narrow window. */
.spending-page .card { padding: 16px; }
.spending-page th a { white-space: normal; }
.spending-page th, .spending-page td { padding: 7px 6px; font-size: 0.85rem; }
.spending-page th { vertical-align: bottom; line-height: 1.25; }
.spending-page td { vertical-align: top; }
.spending-page table { margin-top: 8px; }
/* a narrower window (small laptop, half a screen): a little tighter still, so that even nine-digit amounts keep the page free of a sideways scroll */
@media (max-width: 1250px) and (min-width: 901px) {
  .spending-page .card { padding: 12px; }
  .spending-page th, .spending-page td { padding: 6px 4px; font-size: 0.8rem; }
}

h1 { font-size: 1.5rem; margin-bottom: 4px; }
h2 { font-size: 1.15rem; margin-top: 28px; }
.subtitle { color: var(--muted); margin-top: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { background: #eef2f0; color: var(--muted); font-weight: 600; }
th a { color: inherit; text-decoration: none; white-space: nowrap; }
th a:hover { color: var(--green-dark, #1f5c38); text-decoration: underline; }
tr:hover td { background: #fafcfb; }
tr.row-link { cursor: pointer; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: white;
  background: var(--muted);
  white-space: nowrap;
}
/* a long status label (e.g. "Approuvée (en attente de désignation par le responsable manœuvre)") wraps inside the badge instead of stretching the table */
.badge.badge-wrap { white-space: normal; max-width: 15rem; line-height: 1.3; text-align: center; border-radius: 14px; }
.badge.soumise { background: #4472ba; }
.badge.approuvee { background: var(--green); }
.badge.rejetee { background: var(--red); }
.badge.annulee { background: #6b6b6b; }
.badge.en_traitement { background: var(--orange); }
.badge.livree { background: #7a4fc4; }
.badge.emise { background: #7a4fc4; }
.badge.affectee { background: #7a4fc4; }
.badge.receptionnee { background: #38707a; }
.badge.paie_attente { background: var(--orange); }
.badge.payee { background: var(--green); }
.badge.ouverte { background: var(--orange); }
.badge.resolue { background: var(--green); }
.badge.rejetee { background: #6b6b6b; }
a.admin-tab-btn { text-decoration: none; display: inline-block; }

form.inline { display: inline; }
form.inline + form.inline { margin-left: 6px; }

label { display: block; font-weight: 600; margin: 14px 0 4px; font-size: 0.9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit;
}
textarea { min-height: 80px; }
code { background: #eef2f0; padding: 2px 6px; border-radius: 4px; font-size: 0.92em; }

.status-checkbox-group {
  display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px;
}
.status-checkbox-group label {
  display: inline-flex; align-items: flex-start; gap: 5px; font-weight: normal; margin: 0; white-space: normal; font-size: 0.9rem; max-width: 100%; min-width: 0;
}
/* a long status label wraps inside its own checkbox label instead of overflowing into the next filter */
.status-checkbox-group input[type=checkbox] { width: auto; flex: none; margin-top: 3px; }

/* ---- Listes : barre de filtres, résumé, pagination, cartes d'historique (views/partials/list-*.ejs, history-card.ejs) ---- */
.list-filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.list-filter-field { flex: 1 1 170px; min-width: 0; }
.list-filter-search { flex: 2 1 220px; }
.list-filter-date { flex: 1 1 140px; }
.list-filter-dir { flex: 0 1 150px; }
.list-filter-wide { flex: 2 1 260px; }
.list-filter-actions { margin: 0; }
.list-filter-bar input[type=date] { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit; }
.fcr-page .list-filter-bar input[type=month] { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit; }
.list-hidden-notice { margin: 0 0 10px; }
.list-pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.list-pager .subtitle { margin: 0; }
/* 375 px: first / previous / Page X / Y / next / last on ONE row */
@media (max-width: 480px) {
  .list-pager { gap: 6px; }
  .list-pager .btn.small { padding: 5px 8px; }
  .list-pager .subtitle { font-size: 0.85rem; }
}
.history-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 14px; flex-wrap: wrap; }
.history-card-head h2 { margin: 0 0 6px; }
.history-card-all { font-size: 0.9rem; }
/* a row of an inactive record: the same dimming the lists already apply with an inline style */
tr.row-inactive td { opacity: 0.6; }
/* the row that is "in force" of a versions table (payroll rates): in bold */
tr.row-current td { font-weight: 600; }
/* a cell of free text (an audit detail: a list of addresses, a long sentence) wraps instead of widening the table, but never
   narrower than 14rem: on a phone the table scrolls inside its card rather than squeezing the text into a column of a few letters */
td.wrap-anywhere { overflow-wrap: anywhere; min-width: 14rem; }

.btn {
  display: inline-block;
  background: var(--green);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 5px;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--green-dark); }
.btn.secondary { background: var(--muted); }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }

/* Administration > budget code > "Approbateurs par PTM": one stacked block per line (never a wide table),
   fields that wrap and shrink to the width of the screen (375 px included), no fixed width anywhere. */
.approver-line { border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin: 12px 0; background: #fafcfb; }
.approver-line h3 { margin: 0 0 4px; font-size: 1rem; }
.approver-fields { display: flex; flex-wrap: wrap; gap: 0 14px; }
.approver-fields > div { flex: 1 1 220px; min-width: 0; }
.approver-fields input[type=date] { width: 100%; max-width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit; }
.approver-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.approver-actions form { margin: 0; }
/* a line that requesters can no longer pick (PTM deactivated / approver inactive): red, with its explanation */
.approver-line.has-problem { border-color: #f0b7b7; border-left: 4px solid #c0392b; background: #fdf3f3; }
.approver-badge { color: #b02a2a; font-weight: 600; font-size: 0.85rem; }
.approver-problem { color: #7a2323; margin: 4px 0 10px; font-size: 0.92rem; }

/* "Accès au suivi des dépenses et droits d'approbation" (views/partials/access-card.ejs): the add form's four approval rights as a row of checkboxes
   that wraps to the width of the screen (375 px included); the table of the rows scrolls inside its card. */
.access-fieldset { margin: 14px 0 0; padding: 8px 12px 10px; border: 1px solid var(--border); border-radius: 5px; min-width: 0; }
.access-fieldset legend { font-size: 0.85rem; font-weight: 600; padding: 0 4px; }
.access-flags { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.access-flags label { display: inline-flex; align-items: center; gap: 6px; font-weight: normal; margin: 0; }
.access-flags input[type=checkbox] { width: auto; }
.access-note { font-size: 0.9rem; }
.access-sep { margin: 0 4px; color: var(--muted); }
/* The table of the access card (budget code page, "Accès et droits" of the owner, user page: all inside #acces-budget) scrolls sideways inside its card on a
   phone (375 px: the table is about 570 px wide). Its first column - the person, the code - stays in view while the boxes and the buttons scroll beneath it:
   an OPAQUE background, and the two borders drawn by the cell itself (the borders of a collapsed table do not follow a sticky cell). The page itself never scrolls. */
#acces-budget th:first-child, #acces-budget td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: inset -1px 0 0 var(--border), inset 0 -1px 0 var(--border); }
#acces-budget th:first-child { background: #eef2f0; }
#acces-budget tr:hover td:first-child { background: #fafcfb; }
/* a deactivated account: the row is dimmed, but a sticky cell must stay opaque (the cells passing beneath would show through) - only its content is dimmed */
#acces-budget tr.row-inactive td:first-child { opacity: 1; }
#acces-budget tr.row-inactive td:first-child > * { opacity: 0.6; }
/* on a phone a long name wraps inside its column (at least 7.5 rem: a name and its matricule in a few lines, not one word a line) instead of pushing the boxes out of sight */
@media (max-width: 600px) {
  #acces-budget td:first-child { min-width: 7.5rem; max-width: 11rem; overflow-wrap: anywhere; }
}
/* The filter field in front of a long <select multiple> (views/partials/select-filter.ejs): shown by its script only, so that without JavaScript the list stays as it was. */
.select-filter { margin: 6px 0 8px; }
.select-filter label { margin: 0 0 4px; }
.select-filter input[type=search] { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit; }

.items-table input { padding: 6px 8px; font-size: 0.88rem; }
.error-box { background: #fbe6e6; border: 1px solid #f0b7b7; color: #7a2323; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.info-box { background: #eaf3ff; border: 1px solid #b9d8ff; color: #1c4c7a; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.warning-box { background: #fff4e0; border: 1px solid #f5c27a; border-left: 4px solid #e08a00; color: #7a4300; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
/* Live updates (views/partials/footer.ejs): the banner of a record changed elsewhere stays in sight while scrolling; a list reloaded in the
   background flashes once */
.live-banner { background: #fff4e0; border: 1px solid #f5c27a; border-left: 4px solid #e08a00; color: #7a4300; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; position: sticky; top: 8px; z-index: 40; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12); }
.live-banner-actions { display: flex; gap: 8px; }
@keyframes live-updated-flash { from { box-shadow: 0 0 0 3px rgba(47, 125, 79, 0.45); } to { box-shadow: 0 0 0 3px rgba(47, 125, 79, 0); } }
.live-updated { animation: live-updated-flash 1.5s ease-out; }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 14px 0; }
.meta-grid > div { min-width: 0; }
.meta-grid div span { display: block; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.meta-grid div strong { font-size: 0.98rem; overflow-wrap: break-word; word-break: break-word; }

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-logo { display: block; height: 56px; width: auto; margin: 0 auto 18px; }
.print-header { display: none; }
.print-only { display: none !important; }

.tutorial-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 22, 0.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.tutorial-overlay.open { display: flex; }
.tutorial-modal {
  position: relative;
  background: var(--card);
  border-radius: 10px;
  max-width: 440px;
  width: 100%;
  padding: 28px 26px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.tutorial-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.tutorial-close:hover { color: var(--text); }
.tutorial-logo { height: 40px; width: auto; display: block; margin: 0 auto 14px; }
.tutorial-step h2 { margin-top: 0; font-size: 1.15rem; }
.tutorial-step p { font-size: 0.92rem; line-height: 1.5; }
.tutorial-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.tutorial-dots { display: flex; gap: 6px; }
.tutorial-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--border); }
.tutorial-dot.active { background: var(--green); }
.tutorial-buttons { display: flex; gap: 8px; margin-left: auto; }
.tutorial-buttons [hidden] { display: none; }

.admin-tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.admin-tab-btn {
  background: none; border: none; padding: 10px 18px; font-size: 0.92rem; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.admin-tab-btn:hover { color: var(--text); }
.admin-tab-btn.active { color: var(--green-dark); border-bottom-color: var(--green); }

.receipt-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 16px;
  margin-bottom: 6px;
  border-bottom: 2px solid var(--green);
}
.receipt-logo { height: 56px; width: auto; flex-shrink: 0; }
.receipt-header h1 { margin-bottom: 2px; }

/* "Property Custodian Receipt" and the print-only forms built on the same classes (asset confirmation and disposal request, weekly CNSS
   declaration of the manoeuvres). It used to replicate the legacy GestionRH asset PDF in italic navy Georgia; corrected on 2026-10-15 at the
   owner's request ("corriger la police"): the font of the rest of the application, upright and black, like the payslips and journals. */
.psr-masthead p { margin: 0; }
.psr-title { color: var(--text); font-weight: 700; font-family: inherit; font-size: 1.02rem; }
.psr-subtitle { color: var(--text); font-weight: 700; text-align: center; font-family: inherit; font-size: 1.15rem; margin: 18px 0 14px; }
.psr-declaration { color: var(--text); font-weight: 600; font-family: inherit; margin-bottom: 4px; }
.psr-name { color: var(--text); font-family: inherit; margin-bottom: 16px; }
.psr-table { width: 100%; border-collapse: collapse; }
.psr-table th, .psr-table td { color: var(--text); font-family: inherit; text-align: left; padding: 4px 8px; border: none; font-size: 0.85rem; }
.psr-table thead th { border-bottom: 1px solid var(--text); font-weight: 700; }
.psr-footer { color: var(--text); font-family: inherit; margin-top: 20px; font-size: 0.85rem; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 110;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 3px 0 16px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 111;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 22, 0.45);
    z-index: 105;
  }
  .sidebar-overlay.open { display: block; }

  .app-shell { display: block; }
  .app-main { padding-top: 62px; }
}

@media (max-width: 768px) {
  .container { padding: 16px 14px 40px; }
  h1 { font-size: 1.25rem; }

  table { font-size: 0.82rem; }
  th, td { padding: 6px 8px; }

  .card { padding: 14px; }

  .btn { width: 100%; text-align: center; }
  .btn.small { width: auto; }
  form.inline { display: inline-block; }
  form.inline .btn, form.inline .btn.small { width: auto; }
}

@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: white; }
  .container { max-width: 100%; padding: 0; }
  .card { border: none; padding: 0; overflow: visible; }
}

/* ---- Paie du personnel : statuts d'une paie, bulletin de paie, journal de paie ---- */
.badge.preparee { background: var(--orange); }
.badge.verifiee { background: #4472ba; }
.badge.validee { background: #38707a; }
/* .badge.payee (vert) existe déjà plus haut */

th.num, td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Bulletin de paie : une page A4 portrait par employé à l'impression. */
.bulletin { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 22px; margin-bottom: 22px; }
.bulletin-org { margin: 0; font-weight: 700; font-size: 1.05rem; }
.bulletin-title { text-align: center; font-size: 1.5rem; margin: 14px 0 4px; letter-spacing: 0.04em; }
.bulletin-month { text-align: right; margin: 0 0 12px; }
.bulletin-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; }
.bulletin-table th, .bulletin-table td { border: 1px solid #555; padding: 5px 8px; font-size: 0.86rem; }
.bulletin-table th { background: #eef2f0; color: var(--text); }
.bulletin-items td { padding: 6px 8px; }
.bulletin-net { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 16px 0; font-size: 1.05rem; }
.bulletin-net strong { border: 2px solid #333; padding: 6px 22px; min-width: 150px; text-align: right; font-size: 1.15rem; }
.bulletin-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: 10px; font-size: 0.92rem; break-inside: avoid; }
/* Cachet (stamp): bottom right, 40 x 40 mm like the legacy bulletin-paie-One.php (caption CACHET above, image below). The image is shown whole
   (object-fit: contain), never stretched; it sits in the normal flow under the net a payer block, so it can never overlap it. A draft has the caption only. */
.bulletin-stamp { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-top: 40px; flex: 0 0 auto; }
.bulletin-stamp.with-image { margin-top: 0; }
.bulletin-stamp-img { display: block; width: 40mm; height: 40mm; object-fit: contain; }
/* Aperçu du cachet dans Paramètres de la paie > Cachet des bulletins (taille d'impression, puis miniatures de l'historique) */
.stamp-preview { width: 40mm; height: 40mm; box-sizing: content-box; border: 1px dashed var(--border); border-radius: 4px; padding: 4px; background: #fff; }
.stamp-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.stamp-thumb { display: block; width: 18mm; height: 18mm; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 2px; }
.stamp-current { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; }
.stamp-facts { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.stamp-facts dt { color: var(--muted); }
.stamp-facts dd { margin: 0; overflow-wrap: anywhere; }
.bulletin-draft {
  display: block; width: fit-content; margin: 0 0 12px auto;
  border: 2px solid var(--red); color: var(--red); font-weight: 800; letter-spacing: 0.14em;
  padding: 2px 12px; border-radius: 4px;
}
.table-scroll { overflow-x: auto; }

/* Journal de paie : un bloc par code budget. Sur écran, le tableau défile dans sa carte (jamais coupé, la page elle-même ne déborde pas).
   Le format d'impression du journal (A4 PAYSAGE, marges, "Page X / Y") est déclaré dans views/payroll/journal.ejs par une règle @page simple qui ne
   concerne que cette page : les règles d'impression ci-dessous ne portent que sur .journal-sheet / .journal-watermark. */
.journal-sheet { overflow-x: auto; max-width: 100%; }
.journal-head p { margin: 2px 0; }
.journal-center { text-align: center; }
.journal-table { font-size: 0.74rem; }
.journal-table th, .journal-table td { padding: 4px 6px; border: 1px solid #bbb; }
.journal-table .group-row td { background: #e5ece8; font-weight: 700; }
.journal-table .subtotal td, .journal-table .grand td { font-weight: 700; background: #f4f7f5; }
.journal-signatures { width: auto; min-width: 60%; font-size: 0.8rem; }
.journal-signatures th, .journal-signatures td { border: 1px solid #bbb; padding: 14px 10px; }
.journal-draft { display: inline-block; border: 1.5px solid var(--red); color: var(--red); font-weight: 800; letter-spacing: 0.12em; padding: 0 8px; border-radius: 3px; }
.journal-pct { white-space: nowrap; }
.journal-watermark { display: none; }

/* Pages nommées : seul le contenu de la paie change de format d'impression,
   les autres pages imprimables de l'application ne sont pas touchées. */
@page bulletin { size: A4 portrait; margin: 12mm; }
.bulletins-sheet { page: bulletin; }
@media print {
  .table-scroll { overflow: visible; }
  .app-shell, .app-main { display: block !important; }
  .bulletin { border: none; border-radius: 0; padding: 0; margin: 0; break-after: page; break-inside: avoid; }
  .bulletin:last-of-type { break-after: auto; }
  /* more than 10 rubriques: tighter rows and gaps so that the table, the net a payer and the 40 mm stamp still fit ONE A4 page (measured: 15 rubriques = 970 px of the 1032 px of a page; a payslip of 10 or fewer rubriques is untouched) */
  .bulletin[data-dense] .bulletin-items th, .bulletin[data-dense] .bulletin-items td { padding-top: 2px; padding-bottom: 2px; }
  .bulletin[data-dense] .bulletin-table { margin-bottom: 8px; }
  .bulletin[data-dense] .bulletin-net { margin: 8px 0; }
  .bulletin-table th, .journal-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* ---- Journal de paie sur papier : 16 colonnes sur les 281 mm utiles d'un A4 paysage (marges de 8 mm), police 7 pt.
     Largeurs fixes (colgroup) : matricule et compte étroits, nom qui passe à la ligne au lieu de déborder, 12 colonnes de montants qui se partagent le reste
     (17 mm = 10 chiffres en gras), jamais de retour à la ligne dans un montant, en-têtes qui passent à la ligne. */
  .journal-sheet { overflow: visible; max-width: none; color: #000; font-size: 7pt; line-height: 1.25; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .journal-head p { margin: 0 0 0.8mm; font-size: 8.5pt; }
  .journal-head p.journal-title { font-size: 9.5pt; margin-top: 1.5mm; }
  .journal-draft { border: 0.4mm solid #c0392b; color: #c0392b; font-size: 9pt; padding: 0 2mm; }
  .journal-table { table-layout: fixed; width: 100%; margin: 1.5mm 0 0; border-collapse: collapse; font-size: 7pt; }
  .journal-table col.c-mat { width: 12mm; }
  .journal-table col.c-name { width: 40mm; }
  .journal-table col.c-acc { width: 13mm; }
  .journal-table col.c-ptm { width: 9mm; }
  .journal-table th, .journal-table td { font-size: 7pt; line-height: 1.25; padding: 0.5mm 0.7mm; border: 0.2mm solid #777; vertical-align: top; overflow-wrap: anywhere; }
  .journal-table th { font-size: 6.2pt; line-height: 1.15; vertical-align: bottom; background: #e8e8e8 !important; color: #000; }
  .journal-table th.num, .journal-table td.num { text-align: right; }
  .journal-table th.num { white-space: normal; }
  .journal-table td.num { white-space: nowrap; overflow-wrap: normal; font-variant-numeric: tabular-nums; }
  .journal-table .group-row td { background: #e5ece8 !important; }
  .journal-table .subtotal td { background: #f4f7f5 !important; }
  .journal-table .grand td { background: #dbe5df !important; }
  .journal-sheet.dense .journal-table td.num { font-size: 6.2pt; }
  /* header repeated on every page; the grand total (tfoot) is printed ONCE, after the last block, instead of being repeated on every page */
  .journal-table thead { display: table-header-group; }
  .journal-table tfoot { display: table-row-group; }
  /* no split row; a programme block (header row, lines, subtotal) stays on one page when it fits; the grand total stays with the last block */
  .journal-table tr { break-inside: avoid; page-break-inside: avoid; }
  .journal-table tbody { break-inside: avoid; page-break-inside: avoid; }
  .journal-table .group-row { break-after: avoid; page-break-after: avoid; }
  .journal-table .subtotal { break-before: avoid; page-break-before: avoid; }
  .journal-table tfoot tr { break-before: avoid; page-break-before: avoid; }
  /* agents count and signatures: together, after the table, never alone on a page */
  .journal-end { break-inside: avoid; page-break-inside: avoid; break-before: avoid; page-break-before: avoid; margin-top: 2.5mm; }
  .journal-count { margin: 0 0 2mm; font-size: 8pt; }
  .journal-signatures { width: 62%; min-width: 0; table-layout: fixed; font-size: 7.5pt; margin: 0; }
  .journal-signatures th, .journal-signatures td { font-size: 7.5pt; padding: 1mm 2mm; height: 8mm; border: 0.2mm solid #777; vertical-align: middle; }
  .journal-signatures th { height: auto; background: #e8e8e8 !important; }
  /* PROJET on every printed page (a fixed element is repeated on each page) */
  .journal-watermark { display: block; position: fixed; left: 0; right: 0; top: 30%; text-align: center; font-size: 120pt; font-weight: 800; letter-spacing: 0.12em; color: rgba(192, 57, 43, 0.13); transform: rotate(-22deg); pointer-events: none; z-index: 50; }
}

/* ---- Paie du personnel : Employes > Comptes utilisateurs (lien personnel / comptes par matricule) ---- */
.badge.acc-linked { background: var(--green); }
.badge.acc-candidate { background: #4472ba; }
.badge.acc-none { background: #6b6b6b; }
.badge.acc-multiple { background: var(--orange); }
.badge.acc-conflict { background: var(--red); }
.acc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.acc-chip { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: #fafcfb; color: var(--text); text-decoration: none; font-size: 0.88rem; }
.acc-chip:hover { border-color: var(--green); }
.acc-chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.accounts-table td { vertical-align: top; }
.accounts-table .acc-mail { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.accounts-table .acc-note { color: var(--muted); font-size: 0.86rem; }
.accounts-table .acc-warn { color: #7a4300; font-size: 0.86rem; }
.accounts-table .acc-list { margin: 4px 0 0 18px; padding: 0; }
.accounts-table tr.acc-inactive td { opacity: 0.75; }
.accounts-table .acc-link-form { display: flex; gap: 6px; align-items: center; margin: 6px 0 0; }
.accounts-table .acc-link-form select { min-width: 12rem; padding: 6px 8px; font-size: 0.88rem; }
.accounts-table details.acc-change { margin-top: 8px; }
.accounts-table details.acc-change summary { cursor: pointer; color: var(--green-dark); font-size: 0.86rem; }
@media (max-width: 768px) {
  .accounts-table, .accounts-table tbody, .accounts-table tr, .accounts-table td { display: block; width: 100%; box-sizing: border-box; }
  .accounts-table thead { display: none; }
  .accounts-table tr { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 12px; background: #fff; }
  .accounts-table td { border-bottom: none; padding: 6px 0; overflow-wrap: anywhere; }
  .accounts-table td::before { content: attr(data-label); display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
  .accounts-table .acc-link-form { flex-wrap: wrap; }
  .accounts-table .acc-link-form select { flex: 1 1 100%; min-width: 0; }
}

/* ---- Paie du personnel : envoi des bulletins par e-mail (views/payroll/bulletins-email.ejs; the tables reuse .accounts-table above) ---- */
.badge.bm-ready, .badge.bm-sent { background: var(--green); }
.badge.bm-already_sent { background: #7a4fc4; }
.badge.bm-no_account { background: #6b6b6b; }
.badge.bm-no_email { background: var(--orange); }
.badge.bm-shared_account { background: var(--red); }
.badge.bm-failed { background: var(--red); }
.bm-table form.inline { display: inline; margin: 0; }
.bm-table td .acc-warn { overflow-wrap: anywhere; }

/* ---- Logement (HFS) : journal des recettes et dépenses du site TVC (views/housing/*.ejs) ---- */
.badge.hfs-recette { background: var(--green); }
.badge.hfs-depense { background: #4472ba; }
.badge.hfs-enregistree { background: #38707a; }
.badge.hfs-en_attente { background: var(--orange); }
.hfs-pos, .hfs-amount-recette { color: var(--green-dark); }
.hfs-neg, .hfs-amount-depense { color: var(--red); }
/* an entry voided: still listed, greyed, its amount struck through (it has no effect anywhere) */
tr.hfs-voided td { color: var(--muted); }
tr.hfs-voided td.num, .hfs-struck { text-decoration: line-through; }
.hfs-flash-items { margin: 6px 0 0 18px; padding: 0; }
.hfs-hint { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.hfs-totals { margin: 0 0 10px; }
.hfs-funds em { display: block; font-style: normal; font-size: 0.78rem; color: var(--muted); }
.hfs-funds strong { font-size: 1.05rem; }
.hfs-funds .hfs-balance strong { font-size: 1.25rem; }
/* forms: fields that wrap and shrink to the width of the screen (375 px included), no fixed width anywhere */
.hfs-fields { display: flex; flex-wrap: wrap; gap: 0 14px; }
.hfs-fields > div { flex: 1 1 220px; min-width: 0; }
.hfs-fields > .wide { flex-basis: 100%; }
.hfs-fields input[type=date], .hfs-fields input[type=month], .hfs-fields input[type=file], .hfs-setting-row input[type=date] {
  width: 100%; max-width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit;
}
.hfs-setting { margin: 0 0 18px; }
.hfs-setting-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hfs-setting-row select, .hfs-setting-row input { flex: 1 1 220px; min-width: 0; max-width: 420px; }
.hfs-cat { border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin: 10px 0; background: #fafcfb; }
.hfs-cat.inactive { background: #f1f1f1; }
.hfs-cat-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 0; }
.hfs-cat-actions form { margin: 0; }
.hfs-journal td.wrap-anywhere { min-width: 9rem; }

/* ---- Logement (HFS) : facturation des visiteurs (séjours, factures, reçus, relevés, créances, documents imprimables) ---- */
.badge.bill-draft { background: #6b6b6b; }
.badge.bill-info { background: #4472ba; }
.badge.bill-ok { background: var(--green); }
.badge.bill-warn { background: var(--orange); }
.badge.bill-off { background: #8a8f8d; }
.hfs-subtabs { margin-top: -6px; font-size: 0.9rem; }
.hfs-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 10px; }
.hfs-actions form { margin: 0; }
.hfs-check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.hfs-check input { width: auto; flex: 0 0 auto; }
.hfs-preview { margin: 4px 0 8px; font-weight: 600; color: var(--green-dark); min-height: 1.2em; overflow-wrap: anywhere; }
.hfs-note { display: block; font-style: normal; font-size: 0.78rem; color: var(--muted); }
.hfs-line-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.hfs-line-form input[type=text] { flex: 1 1 200px; min-width: 0; }
.hfs-line-form input[type=number] { flex: 0 1 110px; min-width: 0; }
.hfs-totals-line { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 10px; }
.hfs-edit summary { cursor: pointer; color: var(--green-dark); font-size: 0.86rem; }
.hfs-edit form label { display: block; margin-top: 6px; font-size: 0.8rem; }
.hfs-aging td, .hfs-aging th { vertical-align: top; }
.hfs-late { color: #7a4300; max-width: 22rem; }
.hfs-doc-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
/* Documents imprimables (facture, avoir, reçu, relevé) : une page A4 portrait ; les mêmes données que le PDF du serveur (utils/housingPdf.js). */
.hfs-doc { position: relative; overflow: hidden; background: #fff; color: #000; border: 1px solid var(--border); border-radius: 8px; padding: 26px; margin-bottom: 22px; page: hfsdoc; }
.hfs-doc-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 14px; }
.hfs-doc-company { flex: 1 1 240px; min-width: 0; }
.hfs-doc-company p, .hfs-doc-title p { margin: 2px 0; overflow-wrap: anywhere; }
.hfs-doc-company-name { font-weight: 700; font-size: 1.1rem; }
.hfs-doc-title { text-align: right; flex: 0 1 auto; min-width: 0; }
.hfs-doc-title h1 { margin: 0 0 4px; font-size: 1.7rem; letter-spacing: 0.06em; }
.hfs-doc-pre { white-space: pre-line; overflow-wrap: anywhere; }
.hfs-doc-fields { margin: 0 0 16px; }
.hfs-doc-fields > div { display: flex; gap: 10px; margin: 2px 0; }
.hfs-doc-fields dt { flex: 0 0 9rem; font-weight: 700; }
.hfs-doc-fields dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.hfs-doc-wide dt { flex-basis: 12rem; }
.hfs-doc-table { width: 100%; border-collapse: collapse; margin: 0 0 12px; }
.hfs-doc-table th, .hfs-doc-table td { border: 1px solid #555; padding: 5px 8px; font-size: 0.88rem; overflow-wrap: anywhere; }
/* a header never breaks inside a word ("N / o.", "NOM / BRE"): the cells below may wrap anywhere, the column titles may not */
.hfs-doc-table th { background: #eef2f0; color: #000; text-align: center; white-space: nowrap; overflow-wrap: normal; }
.hfs-doc-table .c { text-align: center; }
.hfs-doc-table .num { text-align: right; white-space: nowrap; }
.hfs-doc-small th, .hfs-doc-small td { font-size: 0.74rem; padding: 3px 5px; }
.hfs-doc-words { font-weight: 600; margin: 14px 0; overflow-wrap: anywhere; }
.hfs-doc-note, .hfs-doc-small-text { font-size: 0.86rem; margin: 6px 0; }
.hfs-doc-signatures { display: flex; justify-content: space-between; gap: 16px; margin: 26px 0 70px; }
.hfs-doc-bank { font-size: 0.8rem; margin: 0 0 6px; }
.hfs-doc-footer { font-size: 0.75rem; text-align: center; color: #444; margin: 0; }
.hfs-doc-void { color: var(--red); }
/* the word (PROJET, ANNULÉ, DRAFT, VOID) is one line that must fit the width of the document: nowrap, a moderate size and letter spacing */
.hfs-doc-watermark { position: absolute; left: 0; right: 0; top: 28%; text-align: center; white-space: nowrap; font-size: 5.2rem; font-weight: 800; letter-spacing: 0.04em; color: rgba(192, 57, 43, 0.13); transform: rotate(-22deg); pointer-events: none; z-index: 5; }
@page hfsdoc { size: A4 portrait; margin: 14mm; }
@media (max-width: 480px) {
  .hfs-doc { padding: 14px; }
  .hfs-doc-fields dt { flex-basis: 6.5rem; }
  .hfs-doc-wide dt { flex-basis: 7.5rem; }
  .hfs-doc-watermark { font-size: 2.8rem; }
  .hfs-doc-title { text-align: left; }
  .hfs-doc-signatures { margin-bottom: 40px; }
  /* the table keeps a readable width and scrolls inside its box (.table-scroll) instead of crushing the words letter by letter */
  .hfs-doc-table { min-width: 30rem; }
  .hfs-doc-table.hfs-doc-small { min-width: 44rem; }
}
@media print {
  .hfs-doc { border: none; border-radius: 0; padding: 0; margin: 0; overflow: visible; }
  /* A4 portrait with 14 mm margins leaves 182 mm (516 pt): ANNULÉ at 84 pt, rotated, takes about 380 pt - it fits whatever the language (PROJET, DRAFT, VOID are narrower) */
  .hfs-doc-watermark { position: fixed; top: 32%; font-size: 84pt; letter-spacing: 0.03em; white-space: nowrap; }
  .hfs-doc-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hfs-doc-table tr { break-inside: avoid; page-break-inside: avoid; }
  .hfs-doc-table thead { display: table-header-group; }
  /* the totals row is printed ONCE, after the last line, not repeated at the bottom of every page (same rule as the payroll journal) */
  .hfs-doc-table tfoot { display: table-row-group; }
  .hfs-doc-signatures, .hfs-doc-bank, .hfs-doc-footer { break-inside: avoid; page-break-inside: avoid; }
}
/* ---- Ajustement manuel de sortie (MRI) : badge, bandeau, formulaire (views/mr/adjustment-new.ejs, views/mr/show.ejs, listes) ---- */
.badge.manual-adjustment { background: #9a5b13; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.manual-adjustment-banner { margin-bottom: 14px; }
.manual-adjustment-banner p { margin: 6px 0 0; }
.manual-adjustment-reason { white-space: pre-line; overflow-wrap: anywhere; }
.error-list { margin: 0; padding-left: 20px; }
input[type=file] { max-width: 100%; }
/* the article rows of the form are stacked blocks, never a wide table: they wrap and shrink to the width of the screen (375 px included) */
.adj-line { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px 10px; margin: 10px 0; background: #fafcfb; }
.adj-line-fields { display: flex; flex-wrap: wrap; gap: 0 12px; }
.adj-field { flex: 1 1 130px; min-width: 0; margin: 0; font-weight: normal; font-size: 0.95rem; }
.adj-field.adj-wide { flex: 3 1 240px; }
.adj-field > span { display: block; margin: 8px 0 3px; font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.adj-field input { width: 100%; box-sizing: border-box; }
.adj-line-actions { margin: 8px 0 0; text-align: right; }

/* ---- Facturation FCR (views/fcr/*.ejs, routes/fcr.js): statuses of an invoice, forms that wrap to the width of the screen (375 px included), asset picker ---- */
.badge.fcr-brouillon { background: #6b6b6b; }
.badge.fcr-emise { background: #7a4fc4; }
.badge.fcr-approuvee { background: var(--green); }
.badge.fcr-contestee { background: #9a5b13; }   /* white on --orange is 4.2 : 1: this brown gives 5.4 : 1 */
.badge.fcr-annulee { background: var(--red); }
.badge.fcr-free { background: #5f6663; }   /* white on this grey: 5.9 : 1 (the grey of the other badges gave 3.3 : 1) */
.fcr-line-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fcr-line-actions form { margin: 0; }
.fcr-line-actions .btn.small { padding: 4px 8px; white-space: nowrap; }
.fcr-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.fcr-actions form { margin: 0; }
.fcr-unit-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fcr-fields { display: flex; flex-wrap: wrap; gap: 0 14px; }
.fcr-fields > div { flex: 1 1 200px; min-width: 0; }
.fcr-fields > .fcr-field-wide { flex: 2 1 320px; }
.fcr-fields input[type=date], .fcr-fields input[type=month] { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 5px; font-size: 0.95rem; font-family: inherit; }
.fcr-items { margin: 6px 0 0; padding-left: 20px; }
.fcr-reason summary { cursor: pointer; font-weight: 600; }
.fcr-check { display: inline-flex; align-items: center; gap: 6px; }
.fcr-picker-list { list-style: none; margin: 2px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 5px; background: var(--card); max-height: 240px; overflow-y: auto; }
.fcr-picker-list li { padding: 7px 10px; cursor: pointer; font-size: 0.9rem; }
.fcr-picker-list li.is-active { background: #eef2f0; }
.fcr-table td, .fcr-table th { vertical-align: top; }
@media (max-width: 768px) {
  .fcr-fields > div, .fcr-fields > .fcr-field-wide { flex-basis: 100%; }
}
/* Paie > Paramètres > Taux CNSS / ANPE: "Évolution des taux" (views/payroll/settings-rates.ejs), one period per line, newest first */
.rate-timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.rate-step { position: relative; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; padding: 0 0 18px 22px; }
.rate-step::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: -8px; width: 2px; background: var(--border); }
.rate-step:last-child { padding-bottom: 0; }
.rate-step:last-child::before { display: none; }
.rate-step::after { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid #9aa6a1; box-sizing: border-box; }
.rate-step.is-current::after { background: var(--green); border-color: var(--green); }
.rate-when { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.rate-from { font-weight: 700; text-transform: capitalize; }
.rate-until { color: var(--muted); font-size: 0.88rem; }
.rate-when .badge { margin-top: 4px; }
.rate-values { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rate-value { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fafbfa; min-width: 0; }
.rate-label { color: var(--muted); font-size: 0.78rem; }
.rate-num { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-before { color: var(--muted); font-size: 0.78rem; }
.rate-value.is-changed { background: #eaf4ee; border-color: #8cc0a1; }
.rate-value.is-changed .rate-num { color: var(--green-dark); }
@media (max-width: 900px) {
  .rate-step { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .rate-when { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
  .rate-when .badge { margin-top: 0; }
  .rate-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* the versions list of the same page: one-line months, a readable "Note" column (the table scrolls sideways on a small screen) */
.rate-versions td:first-child { white-space: nowrap; }
.rate-versions th.num { white-space: normal; min-width: 6.5rem; }
.rate-versions td:nth-child(6) { min-width: 12rem; }

/* Housing: the letterhead model of the invoices on the printable page (views/housing/_letterhead-head.ejs / _letterhead-foot.ejs). The box of the header
   is as tall as "Début du texte" (padding-top in % of the width), the picture sits where Word puts it; the server PDF is the exact document. */
.hfs-lh-head { position: relative; margin: -26px -26px 0; overflow: hidden; }
.hfs-lh-head img { position: absolute; top: 0; max-width: none; }
.hfs-lh-foot { margin-top: 28px; break-inside: avoid; page-break-inside: avoid; }
.hfs-lh-foot table { width: 100%; border-collapse: collapse; table-layout: fixed; font-family: Calibri, Carlito, Arial, sans-serif; color: #58585a; }
.hfs-lh-foot td { vertical-align: top; padding: 0 9px; }
.hfs-lh-foot p { margin: 0; line-height: 1.25; overflow-wrap: anywhere; }
.hfs-lh-foot tr:first-child td { padding-top: 4px; }
.hfs-lh-spacer td { padding: 0; line-height: 0; font-size: 0; }
.hfs-lh-foot-img { display: block; max-width: 100%; margin: 6px auto 0; }
@media (max-width: 768px) { .hfs-lh-head { margin: -14px -14px 0; } }
@media print {
  .hfs-lh-head { margin: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hfs-lh-foot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.hfs-lh-preview { border: 1px dashed var(--border); border-radius: 6px; padding: 10px; background: #fff; }
.hfs-lh-preview > img { display: block; max-width: 100%; max-height: 180px; object-fit: contain; object-position: left top; }

/* The card of the administrator's interventions (RFP, MRI, manoeuvre request, timesheet pages): left out of the print / PDF unless the box
   "Inclure les interventions de l'administrateur dans le PDF" is ticked (views/partials/admin-history-print-toggle.ejs). */
.admin-history-toggle { display: inline-flex; gap: 5px; align-items: center; font-weight: normal; margin: 0; }
.admin-history-toggle input { width: auto; margin: 0; }
@media print { .admin-history-print:not(.print-on) { display: none !important; } }

/* Housing: the occupancy and revenue reports (views/housing/reports.ejs): quick period buttons, KPI tiles, the tables; print-friendly. */
.hfs-rep-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 0; }
.hfs-rep-sep { flex: 1 1 auto; }
.hfs-rep-current { outline: 2px solid var(--primary, #1f5f99); outline-offset: 1px; }
.hfs-rep-kpi > div strong { display: block; font-size: 1.25rem; }
.hfs-rep-table { width: 100%; border-collapse: collapse; }
.hfs-rep-table th, .hfs-rep-table td { vertical-align: top; }
.hfs-rep-table td.num, .hfs-rep-table th.num { white-space: nowrap; }
.hfs-rep-table tfoot td { border-top: 2px solid var(--border); }
.hfs-rep-narrow { width: auto; min-width: 360px; }
.hfs-rep-defs ul { margin: 0; padding-left: 20px; }
.hfs-rep-defs li { margin: 0 0 6px; color: var(--muted); font-size: 0.88rem; }
@media print {
  .hfs-rep-table { font-size: 0.78rem; }
  .hfs-rep-table .hfs-note { display: inline; }
  .hfs-rep-defs, .hfs-rep-table tr { break-inside: avoid; page-break-inside: avoid; }
}

/* Housing: the room planning (views/housing/planning.ejs, GET /logement/planning). Fixed layout: a room column + one narrow column per day (the
   table is as wide as its days need, at least the card); on screen it scrolls sideways INSIDE .hfs-plan-scroll (never the page) with the room
   column kept on the left; printed on A4 landscape it shrinks to the page width. A stay is one cell spanning its nights, coloured by status. */
.hfs-plan-nav { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.hfs-plan-nav .btn { width: auto; }
.hfs-plan-pick { display: flex; gap: 6px; align-items: center; margin: 0; }
.hfs-plan-pick label { margin: 0; font-weight: 600; }
.hfs-plan-pick input[type=month] { width: auto; margin: 0; }
.hfs-plan-card { overflow: visible; }
.hfs-plan-stats { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0 0 10px; }
.hfs-plan-alert { color: var(--red); font-weight: 600; }
.hfs-plan-scroll { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 6px; }
.hfs-plan-table { --hfs-plan-room-w: 11rem; --hfs-plan-day-w: 2.3rem; table-layout: fixed; border-collapse: separate; border-spacing: 0; margin: 0;
  width: calc(var(--hfs-plan-room-w) + var(--hfs-plan-days, 31) * var(--hfs-plan-day-w)); min-width: 100%; }
.hfs-plan-table col.hfs-plan-colroom { width: var(--hfs-plan-room-w); }
.hfs-plan-table col.hfs-plan-colday { width: var(--hfs-plan-day-w); }
.hfs-plan-table th, .hfs-plan-table td { padding: 0; height: 2.2rem; border: 0; border-right: 1px solid #e3e8e5; border-bottom: 1px solid #e3e8e5; font-size: 0.78rem; vertical-align: middle; }
.hfs-plan-table th.hfs-plan-day { text-align: center; line-height: 1.1; padding: 3px 0; color: var(--muted); background: #eef2f0; }
.hfs-plan-table th.hfs-plan-day span { display: block; font-size: 0.68rem; font-weight: 400; }
.hfs-plan-table th.hfs-plan-day strong { display: block; color: var(--text); }
.hfs-plan-table th.hfs-plan-day.hfs-plan-we { background: #e1e7e4; }
.hfs-plan-table th.hfs-plan-day.hfs-plan-today { background: var(--green); color: #fff; }
.hfs-plan-table th.hfs-plan-day.hfs-plan-today strong { color: #fff; }
.hfs-plan-table .hfs-plan-m1 { border-left: 2px solid #9aa6a1; }
.hfs-plan-table th.hfs-plan-roomh, .hfs-plan-table th.hfs-plan-room { position: sticky; left: 0; z-index: 2; background: var(--card); border-right: 2px solid var(--border); }
.hfs-plan-table th.hfs-plan-roomh { background: #eef2f0; padding: 4px 8px; }
.hfs-plan-table th.hfs-plan-room { padding: 3px 8px; color: var(--text); font-weight: 400; white-space: normal; line-height: 1.25; overflow: hidden; }
.hfs-plan-num { font-weight: 700; }
.hfs-plan-name { overflow-wrap: anywhere; }
.hfs-plan-type { display: block; color: var(--muted); font-size: 0.7rem; }
.hfs-plan-hk { display: inline-block; margin: 1px 2px 0 0; padding: 0 5px; border-radius: 3px; font-size: 0.66rem; font-weight: 600; background: #8a8f8d; color: #fff; }
.hfs-plan-hk-hs { background: var(--red); }
.hfs-plan-hk-clean { background: var(--orange); }
.hfs-plan-hk-conflict { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.hfs-plan-table tr.hfs-plan-inactive th.hfs-plan-room { color: var(--muted); }
.hfs-plan-table tr.hfs-plan-lane2 td { height: 1.9rem; }
/* free / busy-elsewhere nights */
.hfs-plan-table td.hfs-plan-free, .hfs-plan-table td.hfs-plan-gap, .hfs-plan-table td.hfs-plan-blank { background: #fff; }
.hfs-plan-table td.hfs-plan-free a { display: block; height: 100%; min-height: 2.1rem; text-decoration: none; }
.hfs-plan-table td.hfs-plan-free a:hover, .hfs-plan-table td.hfs-plan-free a:focus { background: #eaf4ee; outline: 1px solid var(--green); outline-offset: -1px; }
.hfs-plan-table td.hfs-plan-free a:hover::after, .hfs-plan-table td.hfs-plan-free a:focus::after { content: "+"; display: block; text-align: center; line-height: 2.1rem; color: var(--green-dark); font-weight: 700; }
.hfs-plan-table td.hfs-plan-gap { background: repeating-linear-gradient(135deg, #fff 0 4px, #f3e3e3 4px 6px); }
.hfs-plan-table td.hfs-plan-free.hfs-plan-we, .hfs-plan-table td.hfs-plan-blank.hfs-plan-we, .hfs-plan-table td.hfs-plan-sum.hfs-plan-we { background: #f1f3f2; }
.hfs-plan-table td.hfs-plan-free.hfs-plan-today, .hfs-plan-table td.hfs-plan-blank.hfs-plan-today, .hfs-plan-table td.hfs-plan-sum.hfs-plan-today { background: #fff6d1; }
.hfs-plan-table tr.hfs-plan-hs td.hfs-plan-free { background: repeating-linear-gradient(135deg, #f4f4f4 0 5px, #e2e2e2 5px 7px); }
/* stays */
.hfs-plan-table td.hfs-plan-stay { position: relative; overflow: hidden; }
.hfs-plan-table td.hfs-plan-stay a { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 5px; line-height: 2.1rem; color: var(--text); text-decoration: none; border-left: 4px solid transparent; border-radius: 4px; margin: 1px; }
.hfs-plan-table tr.hfs-plan-lane2 td.hfs-plan-stay a { line-height: 1.8rem; }
.hfs-plan-table td.hfs-plan-stay a:hover, .hfs-plan-table td.hfs-plan-stay a:focus { filter: brightness(0.95); text-decoration: underline; }
.hfs-plan-code { font-weight: 700; }
.hfs-plan-table td.hfs-plan-brouillon a, .hfs-plan-swatch.hfs-plan-brouillon { background: #fff0d2; border-color: #d9901a; }
.hfs-plan-table td.hfs-plan-confirme a, .hfs-plan-swatch.hfs-plan-confirme { background: #dbe7fa; border-color: #4472ba; }
.hfs-plan-table td.hfs-plan-facture a, .hfs-plan-swatch.hfs-plan-facture { background: #d6ecdd; border-color: var(--green); }
.hfs-plan-table td.hfs-plan-brouillon a { background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(217, 144, 26, 0.12) 8px 12px); }
.hfs-plan-table td.hfs-plan-conflict a, .hfs-plan-swatch.hfs-plan-conflict { box-shadow: inset 0 0 0 2px var(--red); }
.hfs-plan-table td.hfs-plan-cont-l a { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-style: dotted; }
.hfs-plan-table td.hfs-plan-cont-r a { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.hfs-plan-in, .hfs-plan-out { display: inline-block; margin-right: 3px; font-weight: 700; }
.hfs-plan-in { color: var(--green); }
.hfs-plan-out { color: #555; }
/* totals per day */
.hfs-plan-table tfoot th.hfs-plan-room { font-weight: 600; font-size: 0.74rem; background: #f4f7f5; }
.hfs-plan-table td.hfs-plan-sum { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; background: #f9fbfa; }
.hfs-plan-table tr.hfs-plan-total-occ td, .hfs-plan-table tr.hfs-plan-total-occ th { border-top: 2px solid var(--border); }
/* legend */
.hfs-plan-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; margin: 12px 0 4px; padding: 0; font-size: 0.82rem; }
.hfs-plan-legend li { display: flex; align-items: center; gap: 6px; }
.hfs-plan-swatch { display: inline-block; width: 1.4rem; height: 0.95rem; border: 1px solid #c9d1cd; border-radius: 3px; }
.hfs-plan-swatch.hfs-plan-brouillon, .hfs-plan-swatch.hfs-plan-confirme, .hfs-plan-swatch.hfs-plan-facture { border-left-width: 4px; }
.hfs-plan-swatch.hfs-plan-free { background: #fff; }
.hfs-plan-swatch.hfs-plan-we { background: #f1f3f2; }
.hfs-plan-swatch.hfs-plan-today { background: #fff6d1; }
@media (max-width: 768px) {
  .hfs-plan-table { --hfs-plan-room-w: 7.5rem; --hfs-plan-day-w: 2.1rem; }
  .hfs-plan-nav .btn { width: auto; }
}
@media print {
  .hfs-plan-card { border: none; padding: 0; }
  .hfs-plan-scroll { overflow: visible; border: none; }
  .hfs-plan-table { --hfs-plan-room-w: 30mm; width: 100% !important; min-width: 0; }
  .hfs-plan-table col.hfs-plan-colday { width: auto; }
  .hfs-plan-table th, .hfs-plan-table td { height: 6mm; font-size: 6.5pt; border-color: #bbb; }
  .hfs-plan-table td.hfs-plan-stay a { line-height: 5.5mm; padding: 0 2px; }
  .hfs-plan-table th.hfs-plan-roomh, .hfs-plan-table th.hfs-plan-room { position: static; }
  .hfs-plan-table, .hfs-plan-legend, .hfs-plan-swatch, .hfs-plan-hk { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hfs-plan-table tr { break-inside: avoid; page-break-inside: avoid; }
}

/* Administration > Journal d'activite (views/admin/activity.ejs): the result of each line (white text: 4.5 : 1 or more on each colour) */
.badge.log-ok { background: var(--green); }
.badge.log-refused { background: #9a5b13; }
.badge.log-error { background: var(--red); }
.badge.log-shown { background: #5f6663; }
.activity-table td { vertical-align: top; }
.activity-table .activity-path { font-size: 0.8em; color: #5f6663; word-break: break-all; }
