:root {
  --ink: #1e2b45;
  --ink-soft: #55627a;
  --paper: #f5f6f8;
  --surface: #ffffff;
  --rule: #d6dbe3;
  --rule-soft: #e8ebf0;
  --marker: #f4d03f;
  --ok: #2f7d57;
  --ok-bg: #e5f3ec;
  --warn: #8a5f00;
  --warn-bg: #fff4d1;
  --err: #a3261c;
  --err-bg: #fdecea;
  --focus: #2f6fd6;
  --radius: 6px;
}
* { box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5; font-variant-numeric: tabular-nums;
}
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 22px 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 0 20px 22px; font-weight: 600; line-height: 1.15; }
.brand small { font-weight: 400; opacity: .7; }
.brand-mark { background: var(--marker); color: var(--ink); font-weight: 800; border-radius: 4px; padding: 6px 7px; font-size: 13px; letter-spacing: .5px; }
.side nav { display: flex; flex-direction: column; }
.side nav a { color: #dfe4ee; text-decoration: none; padding: 9px 20px; border-left: 3px solid transparent; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.on { border-left-color: var(--marker); color: #fff; background: rgba(255,255,255,.08); font-weight: 600; }
.logout { margin-top: auto; color: #aab4c6; padding: 0 20px; font-size: .9rem; }

.main { padding: 28px 36px 60px; max-width: 1240px; width: 100%; }
h1 { font-size: 1.75rem; margin: 0 0 12px; line-height: 1.2; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; }
.card > h2:first-child, .card .head-row h2 { margin-top: 0; }
h3 { font-size: 1rem; margin: 18px 0 6px; }
.panel h3 { margin-top: 0; }
.lead { color: var(--ink-soft); max-width: 70ch; margin-top: 0; }
.hint { color: var(--ink-soft); font-size: .87rem; font-weight: 400; }
.sub { color: var(--ink-soft); font-size: .82rem; }
.crumb { margin: 0 0 4px; font-size: .9rem; }
.crumb a { color: var(--ink-soft); }
.nowrap { white-space: nowrap; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1 1 240px; }
.top-gap { margin-top: 16px; }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px 22px; margin: 0 0 18px; }
.panel { background: var(--paper); border: 1px solid var(--rule-soft); border-radius: var(--radius); padding: 14px 16px; }
.empty { border: 1px dashed var(--rule); border-radius: var(--radius); padding: 18px; color: var(--ink-soft); background: var(--surface); margin: 8px 0 14px; }

label { display: block; font-weight: 600; font-size: .88rem; margin: 0 0 12px; }
label.check { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 4px 14px 4px 0; }
label.check.tiny { font-size: .78rem; margin: 1px 8px 1px 0; white-space: nowrap; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 4px; padding: 7px 9px; background: #fff;
}
input[type=checkbox] { width: auto; display: inline-block; margin: 0; accent-color: var(--ink); }
textarea { resize: vertical; line-height: 1.45; }
input:disabled { background: var(--paper); color: var(--ink-soft); }
input.num { text-align: right; }
.narrow-input { max-width: 90px; margin-left: auto; }
fieldset { border: 1px solid var(--rule-soft); border-radius: var(--radius); padding: 10px 14px 12px; margin: 0 0 14px; }
legend { font-weight: 600; font-size: .88rem; padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 18px; }
.grid2.tight { gap: 0 10px; }
.dates { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.dates input { width: 170px; margin: 0; }
.checks { display: flex; flex-wrap: wrap; align-items: center; }
.group-label { width: 100%; font-size: .8rem; color: var(--ink-soft); margin-top: 6px; }
code { background: var(--paper); padding: 1px 5px; border-radius: 3px; font-size: .85em; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none;
  padding: 8px 14px; border-radius: 4px; border: 1px solid var(--rule); background: #fff; color: var(--ink); line-height: 1.2;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2b3b5c; }
.btn.danger { color: var(--err); border-color: #e7c1bd; }
.btn.danger:hover { background: var(--err-bg); }
.btn.ghost { border-style: dashed; color: var(--ink-soft); }
.btn.small { padding: 5px 10px; font-size: .84rem; }
.btn.icon { padding: 3px 9px; font-size: 1.05rem; color: var(--ink-soft); }
form.inline { display: inline; }

.flash { padding: 10px 14px; border-radius: 4px; margin: 0 0 14px; border-left: 4px solid; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok); }
.flash.err { background: var(--err-bg); border-color: var(--err); }
.flash.warn { background: var(--warn-bg); border-color: #d9a400; }
.tag { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 20px; background: var(--rule-soft); color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.card table.list { border-radius: 0; }
table.list th { text-align: left; font-size: .8rem; color: var(--ink-soft); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--rule); background: #fafbfc; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
table.list tbody tr:hover { background: #fbfcfd; }
table.list.compact td { padding: 6px 8px; }
table.list.editable input, table.list.editable select { margin: 0; padding: 5px 7px; }
tr.missing td { background: var(--warn-bg); }
tr.new-row td { background: #fafbfc; }
.journees-cell { max-width: 230px; line-height: 1.1; }
.journees-cell label.check.tiny { display: inline-flex; margin: 1px 6px 1px 0; }
.num { text-align: right; }
.center { text-align: center; }
.table-scroll { overflow-x: auto; margin-bottom: 12px; }

table.postes { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
table.postes th { font-size: .8rem; color: var(--ink-soft); text-align: left; padding: 6px; border-bottom: 1px solid var(--rule); }
table.postes th.num { text-align: right; }
table.postes td { padding: 5px 6px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
table.postes td input, table.postes td select { margin: 0; }
table.postes td:first-child { width: 36%; }
table.postes td:nth-child(2) input, table.postes td:nth-child(4) input { max-width: 110px; margin-left: auto; }
table.postes .q-pct, table.postes .q-auto { display: none; }
table.postes tr[data-mode=pourcentage] .q-fixe { display: none; }
table.postes tr[data-mode=pourcentage] .q-pct { display: block; }
table.postes tr[data-mode=participants] .q-fixe,
table.postes tr[data-mode=vehicules] .q-fixe,
table.postes tr[data-mode=journees] .q-fixe { display: none; }
table.postes tr[data-mode=participants] .q-auto,
table.postes tr[data-mode=vehicules] .q-auto,
table.postes tr[data-mode=journees] .q-auto { display: block; text-align: right; color: var(--ink-soft); font-size: .85rem; }
.total-cell, .alloc .total td, .figures .money dd {
  font-weight: 700;
  background: linear-gradient(transparent 55%, var(--marker) 55%, var(--marker) 90%, transparent 90%);
}
.alloc .counts td { background: #fafbfc; font-size: .85rem; }
.alloc th.num { text-align: right; }

.prix-box { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap;
  border: 1px solid var(--rule); border-left: 4px solid var(--marker); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; background: #fcfcfd; }
.prix-box.fige { border-left-color: var(--ok); background: var(--ok-bg); }
.prix-label { font-size: .8rem; color: var(--ink-soft); }
.prix-val { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.prix-box input { width: 110px; }

.session-head { display: flex; justify-content: space-between; gap: 16px 24px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.session-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.session-head h1 { margin-bottom: 4px; }
.when { margin: 0; color: var(--ink-soft); }
.figures { display: flex; gap: 14px 22px; margin: 0; flex-wrap: wrap; justify-content: flex-end; }
.figures div { text-align: right; }
.figures dt { font-size: .78rem; color: var(--ink-soft); }
.figures dd { margin: 0; font-size: 1.35rem; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; position: sticky; top: 0; background: var(--paper); z-index: 5; padding-top: 6px; flex-wrap: wrap; }
.tabs a { text-decoration: none; padding: 8px 14px; color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: .92rem; }
.tabs a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.count { background: var(--rule-soft); border-radius: 20px; padding: 0 7px; font-size: .78rem; margin-left: 3px; }
section.card { scroll-margin-top: 60px; }
.sub-details { margin: 4px 0 14px; }
.sub-details summary, details.create summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
details.create[open] summary { margin-bottom: 12px; }
.doc-links a { margin-right: 10px; font-weight: 600; white-space: nowrap; }
.doc-links a.muted-link { font-weight: 400; color: var(--ink-soft); font-size: .85rem; margin-left: -6px; }
.danger-zone { justify-content: flex-end; margin-top: 10px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { border-left: none; border-bottom: 3px solid transparent; padding: 6px 10px; }
  .side nav a.on { border-bottom-color: var(--marker); }
  .brand { padding: 0 10px; }
  .logout { margin: 0 0 0 auto; }
  .main { padding: 18px 14px 40px; }
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .figures { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
