/* BL Digital — « Relevé ». Tokens : voir DESIGN.md */
:root {
  --ink: #0f2742; --ink-2: #3b5068; --ink-3: #5b6f86;
  --canvas: #f4f7fa; --surface: #fff; --surface-2: #eaf0f6;
  --hairline: #d6dfe8; --hairline-strong: #b8c6d4;
  --primary: #13648f; --primary-press: #0d4d70; --primary-soft: #e3f1f9;
  --consumed: #0f2742; --reserved: #2f9ac4; --available: #78d4ff;
  --success: #1d6b45; --success-soft: #e4f3ea;
  --warning: #8a4b00; --warning-soft: #fdf1dc;
  --danger: #a8231a; --danger-soft: #fbe8e6;
  --test: #6b3fa0;
  --r-sm: 6px; --r-md: 10px;
  --shadow: 0 1px 2px rgba(15,39,66,.06), 0 4px 16px -8px rgba(15,39,66,.12);
  --ease: cubic-bezier(.2,.8,.2,1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 400 1rem/1.55 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
::selection { background: var(--available); color: var(--ink); }
a { color: var(--primary); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-press); }
:focus-visible { outline: 3px solid rgb(19 100 143 / .45); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: 1.75rem; font-weight: 650; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; margin-top: 1.5rem; }
p { margin: 0 0 .75rem; }
code { font: .875em ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

/* Bandeaux */
.testbar { background: var(--test); color: #fff; text-align: center; font-size: .8125rem; font-weight: 550; padding: .35rem 1rem; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--hairline); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 72rem; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; font-weight: 650; }
.brand img { display: block; }
.brand-sub { color: var(--ink-3); font-weight: 400; font-size: .875rem; padding-left: .5rem; border-left: 1px solid var(--hairline); }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--ink-2); text-decoration: none; padding: .45rem .7rem; border-radius: var(--r-sm); white-space: nowrap; font-size: .9375rem; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-press); font-weight: 550; }
.logout { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.who { color: var(--ink-3); font-size: .875rem; }
.is-admin .topbar { border-bottom-color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

/* Page */
.page { width: 100%; max-width: 72rem; margin: 0 auto; padding: 1.75rem 1rem 3rem; flex: 1; }
.page-narrow { max-width: 38rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head > div { max-width: 46rem; }
.lead { color: var(--ink-2); font-size: 1.0625rem; max-width: 68ch; }
.meta, .meta-inline { color: var(--ink-3); font-size: .8125rem; }
.meta { display: block; margin-top: .15rem; }
.muted { color: var(--ink-3); }
.help { color: var(--ink-3); font-size: .875rem; max-width: 70ch; }
.empty { color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-sm); padding: .9rem 1rem; margin: 0; }
.prose { white-space: pre-line; max-width: 70ch; }
.backlink { display: inline-flex; align-items: center; gap: .35rem; font-size: .875rem; text-decoration: none; }
.foot { text-align: center; color: var(--ink-3); font-size: .8125rem; padding: 1.5rem 1rem 2rem; }
.nowrap { white-space: nowrap; }
.big { font-size: 1.75rem; font-weight: 650; letter-spacing: -.02em; }

.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.panel-action { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.grid-2 { display: grid; gap: 0 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 60rem) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Solde */
.balance-main { display: flex; flex-direction: column; margin-bottom: 1rem; }
.balance-label { font-size: .875rem; font-weight: 550; color: var(--ink-2); }
.balance-figure { font-size: 2.5rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.balance-note { color: var(--ink-3); font-size: .875rem; }
.balance-compact .balance-figure { font-size: 2rem; }
.bar { display: block; width: 100%; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: 1rem; }
.bar-seg { transform-box: fill-box; transform-origin: left; animation: grow .6s var(--ease) both; stroke: var(--surface); stroke-width: 3; vector-effect: non-scaling-stroke; }
@keyframes grow { from { transform: scaleX(0); } }
.seg-consumed { background: var(--consumed); fill: var(--consumed); }
.seg-reserved { background: var(--reserved); fill: var(--reserved); }
.seg-available { background: var(--available); fill: var(--available); }
.seg-credited { background: transparent; box-shadow: inset 0 0 0 2px var(--ink-2); }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; margin: 0 0 .75rem; }
@media (min-width: 40rem) { .legend { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid-2 .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.legend dt { font-size: .8125rem; color: var(--ink-2); display: flex; align-items: center; gap: .4rem; }
.legend dd { margin: 0; }
.legend dd.num { font-size: 1.375rem; font-weight: 650; }
.legend-help { font-size: .75rem; color: var(--ink-3); }
.dot { width: .7rem; height: .7rem; border-radius: 3px; display: inline-block; }

/* Badges, alertes */
.badge { display: inline-block; font-size: .75rem; font-weight: 550; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.badge-neutral { background: var(--surface-2); color: var(--ink-2); }
.badge-muted { background: var(--surface-2); color: var(--ink-3); }
.badge-info { background: var(--primary-soft); color: var(--primary-press); }
.badge-action { background: var(--primary); color: #fff; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--r-sm); margin-bottom: 1rem; font-size: .9375rem; }
.alert .icon { margin-top: .2rem; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--primary-soft); color: var(--primary-press); }
.alert a { color: inherit; font-weight: 600; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .5rem 1rem; border-radius: var(--r-sm); border: 1px solid transparent; font: 550 .9375rem/1.2 var(--font); cursor: pointer; text-decoration: none; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-press); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--hairline-strong); }
.btn-secondary:hover { border-color: var(--ink-2); background: var(--surface-2); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 32px; padding: .3rem .7rem; font-size: .8125rem; }
.btn-block { width: 100%; }
@media (pointer: coarse) { .btn { min-height: 44px; } .btn-sm { min-height: 40px; } }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .75rem 0; }
.stack { display: grid; gap: .6rem; }

/* Formulaires */
.form { display: grid; gap: .35rem; }
.form > button, .form .btn { justify-self: start; margin-top: .6rem; }
.form > .btn-block { justify-self: stretch; }
label, legend { font-size: .875rem; font-weight: 550; color: var(--ink); margin-top: .5rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: var(--r-sm); padding: .55rem .7rem; width: 100%; min-height: 40px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(19 100 143 / .2); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0 0 .5rem; min-width: 0; }
.form-row { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: flex-end; }
.form-row > div { display: grid; gap: .35rem; flex: 1 1 9rem; }
.form-row > .grow { flex: 3 1 14rem; }
.form-row > .form-row-end { flex: 0 0 auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.inline-form input { width: auto; flex: 1 1 7rem; min-height: 32px; padding: .3rem .5rem; font-size: .875rem; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .6rem; margin-top: .4rem; }
.choices-col { grid-template-columns: 1fr; }
.choice { position: relative; display: flex; flex-direction: column; gap: .1rem; padding: .85rem 1rem; border: 1px solid var(--hairline-strong); border-radius: var(--r-md); cursor: pointer; margin: 0; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.choice-row { flex-direction: row; align-items: center; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:hover { border-color: var(--ink-3); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.choice:has(input:focus-visible) { outline: 3px solid rgb(19 100 143 / .45); outline-offset: 2px; }
.choice-main { font-size: 1.125rem; font-weight: 650; }
.choice-row .choice-main { font-size: .9375rem; font-weight: 550; }
.choice-sub { color: var(--ink-2); font-size: .875rem; }
.auth { margin-top: 1.5rem; }

/* Récapitulatif */
.recap { margin: 0 0 1rem; display: grid; }
.recap > div { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--hairline); }
.recap dt { color: var(--ink-2); }
.recap dd { margin: 0; font-weight: 550; text-align: right; }
.recap-total { border-bottom: 0 !important; }
.recap-total dt { font-weight: 650; color: var(--ink); }
.recap-total dd { font-size: 1.375rem; font-weight: 650; }
.figure-line { margin: .25rem 0 .75rem; }
.note { background: var(--surface-2); padding: .6rem .8rem; border-radius: var(--r-sm); white-space: pre-line; }

/* Listes, tableaux */
.list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.list > li { border-bottom: 1px solid var(--hairline); }
.list > li:last-child { border-bottom: 0; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .65rem .25rem; color: var(--ink); text-decoration: none; }
a.list-row:hover { background: var(--canvas); color: var(--ink); }
.table-wrap { overflow-x: auto; margin: 0 -1.25rem; padding: 0 1.25rem; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .75rem; font-weight: 650; color: var(--ink-2); text-transform: none; background: var(--surface-2); padding: .5rem .65rem; white-space: nowrap; }
.table th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.table th:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.table td { padding: .65rem; border-bottom: 1px solid var(--hairline); vertical-align: top; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table-dense td { padding: .4rem .65rem; font-size: .8125rem; }
.neg { color: var(--danger); }
.pos { color: var(--success); }
.details-cell { max-width: 28rem; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: .25rem; }
.tabs a { padding: .35rem .75rem; border-radius: 999px; text-decoration: none; color: var(--ink-2); white-space: nowrap; font-size: .875rem; border: 1px solid var(--hairline); background: var(--surface); }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Admin */
.todo { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.todo-item { display: flex; flex-direction: column; padding: 1rem; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); text-decoration: none; color: var(--ink-2); font-size: .875rem; transition: border-color .15s var(--ease); }
.todo-item:hover { border-color: var(--primary); color: var(--ink); }
.todo-item .big { color: var(--ink); }
.drafts { display: grid; gap: .75rem; margin-bottom: 1rem; }
.draft { border: 1px solid var(--hairline); border-radius: var(--r-md); padding: .9rem 1rem; background: var(--canvas); }
.draft header { margin-bottom: .35rem; }
.details { margin-top: 1rem; border-top: 1px solid var(--hairline); padding-top: .75rem; }
.details summary { cursor: pointer; color: var(--primary); font-weight: 550; display: inline-flex; gap: .4rem; align-items: center; }
.copy { display: inline-block; margin: .35rem 0; user-select: all; }

/* Fil d'échanges */
.timeline { list-style: none; margin: 0 0 1rem; padding: 0; }
.timeline li { padding: .55rem 0 .55rem 1rem; border-left: 2px solid var(--hairline); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .95rem; width: 8px; height: 8px; border-radius: 50%; background: var(--hairline-strong); }
.tl-when { color: var(--ink-3); font-size: .75rem; margin-right: .5rem; }
.tl-who { font-weight: 550; font-size: .875rem; }
.tl-what { font-size: .875rem; color: var(--primary-press); margin-left: .35rem; }
.tl-note { margin: .25rem 0 0; white-space: pre-line; }

@media (max-width: 40rem) {
  h1 { font-size: 1.5rem; }
  .page { padding-top: 1.25rem; }
  .panel { padding: 1rem; }
  .table-wrap { margin: 0 -1rem; padding: 0 1rem; }
  .brand-sub, .who { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  .logout .btn span { display: none; }
  .page-head .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Ajustements après revue des captures */
.panel-head { flex-wrap: wrap; }
.panel-head .btn, .panel-head > a { white-space: nowrap; }
.table td.r { white-space: nowrap; }
.brand img { border-radius: 6px; }
