/* FIDH — Plateforme de gestion des frais de mission
   Feuille de style unique, sans dépendance externe. */

:root {
  --ink: #16202b;
  --ink-soft: #5a6a7a;
  --line: #dfe5ec;
  --bg: #f4f6f9;
  --card: #ffffff;
  --brand: #1b4b8f;
  --brand-dark: #133562;
  --ok: #1f7a4d;
  --warn: #9a6400;
  --err: #a52a2a;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand); }

/* ---------- Barre supérieure ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--brand); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 600; }
.brand-mark {
  background: #fff; color: var(--brand);
  padding: 2px 7px; border-radius: 4px; font-weight: 800; letter-spacing: .5px;
}
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: #dbe6f6; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 14px;
}
.nav a:hover { background: var(--brand-dark); color: #fff; }
.nav a.active { background: var(--brand-dark); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.who { color: #dbe6f6; }
.who em { font-style: normal; opacity: .75; }
.lang-switch {
  color: #fff; text-decoration: none; border: 1px solid rgba(255,255,255,.5);
  padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
}

/* ---------- Structure ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.card h2 { margin-top: 0; }
.muted { color: var(--ink-soft); font-size: 13px; }
.empty { color: var(--ink-soft); padding: 24px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Indicateurs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0 8px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.kpi-wide { grid-column: span 2; }
.kpi-val { font-size: 22px; font-weight: 700; }
.kpi-lbl { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { background: #eef2f7; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; white-space: nowrap; }
.table-compact th { width: 220px; color: var(--ink-soft); font-weight: 600; }

/* ---------- Formulaires ---------- */
.form-card, .login-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.login-card { max-width: 400px; margin: 40px auto; }
fieldset { border: none; border-top: 1px solid var(--line); padding: 16px 0 4px; margin: 0 0 8px; }
fieldset:first-of-type { border-top: none; padding-top: 0; }
legend { font-weight: 600; font-size: 14px; color: var(--brand); padding: 0 8px 0 0; }
.field { margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 6px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
textarea { resize: vertical; }
.inline { display: flex; gap: 8px; }
.inline select { max-width: 110px; }
.hint { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 4px; font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.filters input, .filters select { width: auto; min-width: 180px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #eef2f7; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-approve { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-approve:hover { background: #17603b; }
.btn-reject { background: #fff; border-color: #f0c2c2; color: var(--err); }
.btn-reject:hover { background: #fdeeee; }

/* Bouton de déconnexion : il vit sur la barre bleue, donc texte clair. */
.btn-logout {
  display: inline-block; padding: 5px 12px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.55); background: transparent;
  color: #fff; text-decoration: none; font-size: 13px; font-weight: 600;
}
.btn-logout:hover { background: rgba(255,255,255,.15); }

/* Compteur « À valider » */
.pill {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px;
  background: #fff; color: var(--brand); border-radius: 99px;
  font-size: 11px; font-weight: 800; text-align: center; line-height: 18px;
}

.card-action { border-color: var(--brand); border-width: 2px; }
.step-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.step-comment {
  margin: 6px 0 0; padding-left: 12px; border-left: 2px solid var(--line);
  font-size: 13.5px; color: var(--ink-soft); font-style: italic;
}
.field.check label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.field.check input[type=checkbox] { width: auto; }
.row-inactive { opacity: .55; }
.transcript {
  background: #16202b; color: #d7e3f2; padding: 14px; border-radius: 6px;
  font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* ---------- Messages ---------- */
.alert { padding: 11px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; border: 1px solid; }
.alert-success { background: #eaf6ef; border-color: #b9e0c9; color: var(--ok); }
.alert-error   { background: #fdeeee; border-color: #f0c2c2; color: var(--err); }
.alert-warning { background: #fdf5e4; border-color: #eddcae; color: var(--warn); }

/* ---------- Pastilles de statut ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  background: #eef2f7; color: var(--ink-soft); border: 1px solid var(--line);
}
.badge-submitted { background: #fdf5e4; color: var(--warn); border-color: #eddcae; }
.badge-approved  { background: #eaf6ef; color: var(--ok);   border-color: #b9e0c9; }
.badge-rejected  { background: #fdeeee; color: var(--err);  border-color: #f0c2c2; }
.badge-closed    { background: #e8eaee; color: #4a5462; }

/* ---------- Listes de définitions ---------- */
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
.dl dt { color: var(--ink-soft); font-weight: 600; }
.dl dd { margin: 0; }

/* ---------- Workflow ---------- */
.steps { list-style: none; padding: 0; margin: 0; }
.step {
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
  padding: 10px 12px; border-left: 3px solid var(--line); margin-bottom: 6px; background: #fafbfd;
}
.step-approved { border-left-color: var(--ok); }
.step-rejected { border-left-color: var(--err); }
.step-pending  { border-left-color: var(--warn); }
.step-name { font-weight: 600; }
.step-status { font-size: 13px; color: var(--ink-soft); }

.files { list-style: none; padding: 0; margin: 0; }
.files li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.files li:last-child { border-bottom: none; }
.perdiem-line { font-size: 16px; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* ---------- Pied de page ---------- */
.foot {
  max-width: 1100px; margin: 0 auto; padding: 16px;
  display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 12px;
}

/* ---------- Mobile / tablette (TDR 4) ---------- */
@media (max-width: 800px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-wide { grid-column: span 2; }
  .cols, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .topbar { gap: 12px; }
  .topbar-right { width: 100%; margin-left: 0; }
}

/* ---------- Lot 3 : dépenses et rapprochement ---------- */
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions { white-space: nowrap; }
.row-actions .btn { padding: 4px 8px; font-size: 13px; }
.btn-danger { color: var(--err); }
.row-flagged { background: #fffaf0; }
.flag { color: var(--warn); font-weight: 600; }

.table tfoot th { background: #eef2f7; font-size: 13px; padding: 10px 12px; }
.table tfoot .num { text-align: right; }

.recon { max-width: 460px; }
.recon-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px;
}
.recon-total {
  border-bottom: none; border-top: 2px solid var(--ink);
  margin-top: 4px; padding-top: 12px; font-size: 16px;
}
.recon-total.owes-org strong   { color: var(--err); }
.recon-total.owes-staff strong { color: var(--ok); }

@media (max-width: 800px) {
  .row-actions { white-space: normal; }
  .recon { max-width: none; }
}

/* Annulation */
.card-danger { border-color: #f0c2c2; }
.badge-cancelled { background: #f4e4e4; color: var(--err); border-color: #f0c2c2; }
.step-cancelled { border-left-color: #cbd3dc; opacity: .7; }

/* ---------- Paramètres / référentiels ---------- */
.ref-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.ref-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-decoration: none; color: var(--ink);
}
.ref-card:hover { border-color: var(--brand); background: #fbfcfe; }
.ref-card-title { font-weight: 700; color: var(--brand); }
.ref-card-desc  { font-size: 13px; color: var(--ink-soft); line-height: 1.45; }
.ref-card-count { font-size: 12px; color: var(--ink-soft); margin-top: auto; padding-top: 6px; }
.checkline { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.checkline input[type=checkbox] { width: auto; }
input[disabled] { background: #eef2f7; color: var(--ink-soft); }
@media (max-width: 800px) { .ref-grid { grid-template-columns: 1fr; } }

/* ---------- Rapports ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0 8px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 9px 14px; text-decoration: none; color: var(--ink-soft);
  border: 1px solid transparent; border-bottom: none; font-size: 14px; font-weight: 600;
  border-radius: 6px 6px 0 0;
}
.tab:hover { background: #eef2f7; color: var(--ink); }
.tab.active { background: var(--card); border-color: var(--line); color: var(--brand); margin-bottom: -1px; }
.filter-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.filter-inline input { width: auto; }
.export-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 16px; }
.export-bar .btn { padding: 6px 14px; font-size: 13px; }
.export-format {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.export-format:last-of-type { border-bottom: none; }
@media (max-width: 800px) { .tabs { overflow-x: auto; flex-wrap: nowrap; } .tab { white-space: nowrap; } }

/* --- Suivi budgétaire : graphique et note de lecture (TDR 3.8) --- */
.chart-card { padding: 14px 16px 6px; overflow-x: auto; }
.chart { display: block; min-width: 760px; max-width: 100%; height: auto; }
.chart text { font-family: inherit; }
.note { margin: 10px 0 16px; }
.note summary {
  cursor: pointer; font-size: 13px; color: var(--brand);
  padding: 6px 0; user-select: none;
}
.note summary:hover { text-decoration: underline; }
.note p { margin: 6px 0 0; line-height: 1.55; }

.pager { display: flex; align-items: center; gap: 14px; margin: 14px 0 24px; }
.pager-pos { font-size: 13px; color: var(--ink-soft); }

/* ---------- Left menu: floating dark panel, collapsible icon rail ---------- */
.vshell { display: flex; align-items: flex-start; gap: 0; }
.vshell > .main { flex: 1; min-width: 0; margin: 0; max-width: none; padding-left: 28px; padding-right: 28px; }
.vshell > .main > * { max-width: 1240px; }
.vside { --vs-w: 236px; width: var(--vs-w); flex-shrink: 0; margin: 14px 0 14px 14px; padding: 10px 8px; background: var(--vs-bg, #14232b); color: #c8d3d6;
  border-radius: 18px; position: sticky; top: 14px; height: calc(100vh - 28px); overflow-y: auto; overflow-x: hidden; transition: width .2s ease;
  box-shadow: 0 8px 28px rgba(20,35,43,.18); scrollbar-width: thin; scrollbar-color: #2e434d transparent; }
.vside a, .vside .vs-toggle { display: flex; align-items: center; gap: 12px; padding: 9px 11px; margin: 1px 0; border-radius: 10px; color: #c8d3d6;
  text-decoration: none; white-space: nowrap; font-size: .9375rem; position: relative; border: 0; background: transparent; font-family: inherit; width: 100%; text-align: left; box-sizing: border-box; }
.vside a:hover, .vside .vs-toggle:hover { background: #22363f; color: #fff; }
.vside a.is-active { background: var(--vs-active, #2e6da4); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.vside .vs-i { width: 20px; height: 20px; flex-shrink: 0; }
.vside .vs-l { overflow: hidden; text-overflow: ellipsis; }
.vside .vs-b { margin-left: auto; background: #f2c14e; color: #1d2a2e; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; line-height: 1.5; }
.vside .vs-toggle { cursor: pointer; font-size: .8125rem; color: #8ea0a6; margin-bottom: 6px; }
.vside a.vs-cta { background: #f2c14e; color: #1d2a2e; font-weight: 600; margin-bottom: 4px; }
.vside a.vs-cta:hover { background: #f5cf6f; color: #1d2a2e; }
.vside a.vs-cta.vs-cta-out { background: transparent; color: #f2c14e; box-shadow: inset 0 0 0 1.5px #f2c14e; }
.vside a.vs-cta.vs-cta-out:hover { background: rgba(242,193,78,.12); }
.vside .vs-h { font-size: .6875rem; letter-spacing: .09em; color: #71858c; padding: 14px 11px 4px; white-space: nowrap; text-transform: uppercase; }
#vs-tip { position: fixed; transform: translateY(-50%); background: #14232b; color: #fff; font-size: .8125rem; font-weight: 600; padding: 6px 10px; border-radius: 8px;
  pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.25); white-space: nowrap; }
#vs-tip.show { opacity: 1; }
body.vs-mini .vside { --vs-w: 64px; }
body.vs-mini .vside .vs-l { display: none; }
body.vs-mini .vside a, body.vs-mini .vside .vs-toggle { justify-content: center; padding: 10px 0; gap: 0; }
body.vs-mini .vside .vs-b { position: absolute; top: 3px; right: 5px; margin: 0; font-size: 9.5px; padding: 0 5px; }
body.vs-mini .vside .vs-h { padding: 8px 0 4px; height: 14px; }
body.vs-mini .vside .vs-h span { display: none; }
body.vs-mini .vside .vs-h::after { content: ""; display: block; border-top: 1px solid #2a3e47; margin: 0 10px; }
body.vs-mini .vside .vs-toggle svg { transform: scaleX(-1); }
.vs-burger { display: none; background: none; border: 0; padding: 6px; margin-right: 4px; cursor: pointer; color: inherit; }
@media (max-width: 900px) {
  .vs-burger { display: inline-flex; }
  .vside { position: fixed; left: -280px; top: 0; height: 100vh; margin: 0; border-radius: 0 18px 18px 0; z-index: 50; transition: left .2s; }
  body.vs-open .vside { left: 0; }
  body.vs-mini .vside { --vs-w: 236px; }
  body.vs-mini .vside .vs-l, body.vs-mini .vside .vs-h span { display: inline; }
  body.vs-mini .vside a { justify-content: flex-start; padding: 9px 11px; gap: 12px; }
  .vside .vs-toggle { display: none; }
  .vshell > .main { padding-left: 16px; padding-right: 16px; }
}
@media print { .vside, #vs-tip, .vs-burger { display: none !important; } .vshell > .main { padding: 0; } }
.vside { --vs-active: var(--brand); --vs-bg: #12223a; }
.vshell > .main.wrap { max-width: none; margin: 0; padding: 24px 28px 60px; }
.vshell > .main.wrap > * { max-width: 1100px; }
.has-vs .foot { padding-left: 278px; }
body.has-vs.vs-mini .foot { padding-left: 106px; }
@media (max-width: 900px) { .has-vs .foot { padding-left: 16px; } .vshell > .main.wrap { padding: 20px 16px 60px; } .vs-burger { color: #fff; } }

/* ---------- Aide en ligne ---------- */
.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;
}

.help-search {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 4px 0 18px;
  position: sticky; top: 0; z-index: 5;
  background: var(--bg); padding: 10px 0;
}
.help-search input[type="search"] {
  flex: 1 1 320px; min-width: 220px;
  padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--ink);
}
.help-search input[type="search"]:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
.help-count { font-size: 13px; color: var(--ink-soft); }

/* Sommaire : groupes repartis en colonnes equilibrees par le navigateur.
   Avec des groupes de tailles inegales, une colonne figee par groupe
   laisserait de larges vides sous les plus courts. */
.help-toc {
  margin: 0 0 22px; padding: 18px 22px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  columns: 3; column-gap: 34px;
}
.help-tocg { break-inside: avoid; margin-bottom: 18px; }
.help-tocg:last-child { margin-bottom: 0; }
.help-tocg h3 {
  margin: 0 0 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--ink-soft);
}
.help-tocg ul { list-style: none; margin: 0; padding: 0; }
.help-tocg li { margin-bottom: 1px; }
.help-tocg a {
  display: block; padding: 5px 9px; margin-left: -9px;
  font-size: 14px; line-height: 1.35; color: var(--ink);
  text-decoration: none; border-radius: 5px;
}
.help-tocg a:hover { background: #eef3fa; color: var(--brand); }

@media (max-width: 900px) { .help-toc { columns: 2; } }
@media (max-width: 560px) { .help-toc { columns: 1; padding: 14px 16px; } }

.help-section { scroll-margin-top: 72px; }
.help-section h2 {
  margin-top: 0; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.help-section p { line-height: 1.6; }
.help-list { line-height: 1.6; padding-left: 20px; }
.help-list li { margin-bottom: 5px; }

.help-note {
  margin: 14px 0; padding: 12px 16px;
  background: #f2f5f8; border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.help-note strong { display: block; margin-bottom: 6px; }
.help-note p { margin: 0 0 6px; font-size: 14px; }
.help-note p:last-child { margin-bottom: 0; }

/* Retour en haut : discret, en fin de section, aligne a droite.
   Simple ancre : aucun JavaScript, donc fonctionne aussi quand la
   politique de securite du contenu bloque tout le reste. */
.help-top { margin: 18px 0 0; text-align: right; }
.help-top a {
  font-size: 12.5px; color: var(--ink-soft); text-decoration: none;
  padding: 4px 8px; border-radius: 5px;
}
.help-top a:hover { color: var(--brand); background: #eef3fa; }

/* L'ancre vise le titre de la page : on degage la hauteur du champ de
   recherche, qui est colle en haut. */
#help-haut { scroll-margin-top: 16px; }

.help-empty { margin: 30px 0; }
.help-foot { margin-top: 26px; font-size: 13px; }

@media (max-width: 640px) {
  .help-search { position: static; }
  .help-toc { gap: 6px 12px; padding: 12px; }
}
