/*
 * benk : feuille de style unique. Palette, typographie et mise en page de docs/maquette.html.
 * Thème clair ou sombre suivant le système (R7.8) : toutes les couleurs sont des variables.
 * Aucun défilement horizontal dès 360 px (R7.7) : chaque élément de grille ou de flex a
 * `min-width: 0` et les textes longs peuvent se couper (`overflow-wrap: anywhere`).
 */

:root {
  color-scheme: light dark;
  --bg: #f3f5f8; --surface: #ffffff; --fg: #18202e; --muted: #5b6577; --line: #dde2ea;
  --accent: #2f4fb8; --accent-soft: #e6ebfa; --on-accent: #ffffff;
  --credit: #1f7a55; --credit-soft: #e3f3ec; --debit: #b4321f; --debit-soft: #fbe7e3;
  --pending: #8a6400; --pending-soft: #fbf2d9; --scrim: rgba(16, 22, 34, .45);
  --shadow: rgba(0, 0, 0, .14);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d; --surface: #1a202b; --fg: #e8ecf3; --muted: #9aa4b6; --line: #2a3240;
    --accent: #8ea6ff; --accent-soft: #232c45; --on-accent: #11151d;
    --credit: #5fd09d; --credit-soft: #16302a; --debit: #ff8f7a; --debit-soft: #3a1f1a;
    --pending: #e9c25a; --pending-soft: #362c12; --scrim: rgba(0, 0, 0, .6);
    --shadow: rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; overflow-wrap: anywhere; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 500; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: .25rem 0; width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.label { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.small { font-size: .8rem; }
.pad { padding: .6rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.amount { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tone-neg { color: var(--debit); }
.tone-pos { color: var(--credit); }
svg.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.boot { padding: 2rem 16px; text-align: center; color: var(--muted); }

/* Boutons */
.btn { display: inline-flex; gap: .45rem; align-items: center; justify-content: center; font-weight: 700; padding: .6rem 1.1rem;
  border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--on-accent); transition: background-color .15s; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.danger { background: transparent; color: var(--debit); border-color: var(--debit); }
.btn.start { justify-self: start; }

/* Barre supérieure */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 60rem; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: .75rem; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.1rem; margin-right: auto; display: flex; align-items: center; gap: .5rem; }
.brand-center { justify-content: center; margin: 0; }
.brand .mark { width: 1.6rem; height: 1.6rem; border-radius: 6px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: .9rem; }
.iconbtn { position: relative; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.badge { position: absolute; top: -.35rem; right: -.35rem; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem; border-radius: 999px;
  background: var(--debit); color: var(--surface); font-size: .7rem; font-weight: 700; display: grid; place-items: center; }
.selector { display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); max-width: 15rem; min-width: 0; }
.selector .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.avatar-btn { border: 0; padding: 0; cursor: pointer; }
.avatar { width: 2.2rem; height: 2.2rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.anchor { position: relative; min-width: 0; }

/* Menus déroulants */
.menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 6; width: min(22rem, calc(100vw - 32px)); max-height: calc(100vh - 6rem); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px var(--shadow); padding: .4rem; display: grid; gap: .15rem; }
.menu .item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem 1rem; align-items: center; text-align: left; padding: .55rem .65rem; border: 0; border-radius: 8px; background: transparent; }
.menu .item:hover, .menu .item[aria-current="true"] { background: var(--accent-soft); }
.menu .item .nm { overflow-wrap: anywhere; font-weight: 700; }
.menu .item .sub { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.menu .item .tag { grid-column: 1 / -1; justify-self: start; }
.menu .create { color: var(--accent); font-weight: 700; display: flex; gap: .5rem; align-items: center; }
.menu-head { padding: .4rem .65rem; display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.notif { display: grid; gap: .15rem; padding: .6rem .65rem; border-radius: 8px; overflow-wrap: anywhere; }
.notif.unread { background: var(--accent-soft); }
.notif time { font-size: .78rem; color: var(--muted); }

/* Mise en page */
main { max-width: 60rem; margin: 0 auto; padding: 1.5rem 16px 3rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; min-width: 0; }
.narrow { max-width: 40rem; width: 100%; justify-self: center; }
.err { color: var(--debit); font-size: .85rem; overflow-wrap: anywhere; }

/* Bandeau Banque et accès */
.bank-band { position: relative; display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--line); }
.bank-id { display: flex; gap: .9rem; align-items: center; min-width: 0; }
.bank-glyph { width: 3rem; height: 3rem; border-radius: 12px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.bank-glyph svg.i { width: 1.6rem; height: 1.6rem; }
.bank-text { display: grid; min-width: 0; }
.bank-name { font-family: var(--display); font-size: clamp(1.6rem, 6vw, 2.2rem); font-weight: 700; line-height: 1.1; overflow-wrap: anywhere; }
.access-btn { display: flex; align-items: center; gap: .6rem; padding: .3rem .7rem .3rem .4rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.stack { display: flex; }
.stack .avatar { width: 1.9rem; height: 1.9rem; font-size: .7rem; border: 2px solid var(--surface); margin-left: -.5rem; }
.stack .avatar:first-child { margin-left: 0; }
.stack .avatar.more { background: var(--bg); color: var(--muted); }
.person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .5rem .65rem; }
.person .avatar { width: 2rem; height: 2rem; font-size: .72rem; }
.who { min-width: 0; display: grid; }
.who-name { overflow-wrap: anywhere; }
.hint { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.person .r { font-size: .8rem; color: var(--muted); }
.person-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }

/* Titre, bandeaux de proposition, solde */
.acct-id { display: grid; gap: .2rem; min-width: 0; }
.title { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; }
.role { font-size: .8rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.banner { display: grid; gap: .6rem; border-color: var(--pending); background: var(--pending-soft); }
.banner p { overflow-wrap: anywhere; }
.summary { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.summary-main { display: grid; gap: .4rem; min-width: 0; }
.solde-label { font-family: var(--display); font-size: 1.5rem; font-weight: 500; color: var(--muted); }
.big { font-family: var(--display); font-size: clamp(2rem, 8.5vw, 4.75rem); font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .5rem 2rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.facts > div { display: grid; }
.acts { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Listes de transactions : une seule présentation pour les trois listes */
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pending-box { border-color: var(--pending); background: var(--pending-soft); }
.tx { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) auto minmax(6rem, auto); gap: .2rem 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: 0; }
.tx > * { min-width: 0; }
.tx-date { font-size: .9rem; color: var(--muted); }
.tx-main { grid-column: 2; }
.tx-amount, .tx-balance { text-align: right; }
.tx-balance { color: var(--muted); font-size: .9rem; }
.tx-acts { grid-column: 2 / -1; }
.tx-acts:empty { display: none; }
.tx > .err { grid-column: 2 / -1; }
.lib { font-weight: 700; overflow-wrap: anywhere; }
.by { font-size: .8rem; color: var(--muted); display: flex; gap: .2rem .6rem; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.tag { font-size: .72rem; padding: .05rem .45rem; border-radius: 6px; white-space: nowrap; display: inline-block; }
.tag.emprunt { background: var(--debit-soft); color: var(--debit); }
.tag.remb { background: var(--credit-soft); color: var(--credit); }
.tag.wait { background: var(--pending-soft); color: var(--pending); border: 1px solid var(--pending); }
.tag.refused { background: var(--debit-soft); color: var(--debit); }
.attach { display: inline-flex; gap: .2rem; align-items: center; color: var(--accent); min-width: 0; }
.attach span { overflow-wrap: anywhere; }
.fold-head { font-size: 1rem; }
.fold { display: flex; align-items: center; gap: .5rem; width: 100%; padding: 0; border: 0; background: none; font: inherit; font-weight: 500; text-align: left; overflow-wrap: anywhere; }
.fold[aria-expanded="true"] svg.i { transform: rotate(180deg); }
.fold-head + ul { margin-top: .6rem; }

/* Formulaires et modale */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.field { display: grid; gap: .25rem; min-width: 0; }
.field input { font: inherit; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; min-width: 0; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; }
.guests { display: grid; gap: .5rem; }
.guest { display: flex; gap: .5rem; align-items: center; }
.guest input { flex: 1; min-width: 0; font: inherit; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
.x { border: 0; background: none; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 6px; color: var(--muted); flex: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; padding: .2rem; gap: .2rem; }
.seg label { position: relative; min-width: 0; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: .5rem; border-radius: 8px; font-weight: 700; color: var(--muted); overflow-wrap: anywhere; }
.seg input:checked + span { background: var(--accent-soft); color: var(--fg); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.drop { position: relative; display: flex; gap: .6rem; align-items: center; padding: .8rem; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: .9rem; cursor: pointer; }
.drop span { min-width: 0; overflow-wrap: anywhere; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.notice { display: flex; gap: .5rem; align-items: flex-start; font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
.scrim { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; overflow: auto; background: var(--scrim); }
.dialog { width: min(32rem, 100%); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 16px; background: var(--surface); color: var(--fg); }
.dialog:focus { outline: none; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.dlg-body { padding: 1.25rem; }

/* Connexion */
.login { min-height: 70vh; display: grid; place-items: center; padding: 1.5rem 16px; }
.login .card { max-width: 24rem; width: 100%; display: grid; gap: 1.1rem; text-align: center; padding: 2rem 1.5rem; justify-items: center; }
.gbtn { display: inline-flex; gap: .7rem; align-items: center; justify-content: center; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 700; text-decoration: none; }

@media (max-width: 40rem) {
  .brand .txt { display: none; }
  .selector { max-width: 9.5rem; }
  .summary { grid-template-columns: minmax(0, 1fr); }
  /* Les menus occupent la largeur de l'écran, sous la barre ou sous le bandeau. */
  .anchor { position: static; }
  .topbar .menu { left: 16px; right: 16px; width: auto; }
  .bank-band .menu { left: 0; right: 0; width: auto; }
  .tx { grid-template-columns: minmax(0, 1fr) auto; }
  .tx-main { grid-column: 1; grid-row: 1; }
  .tx-amount { grid-column: 2; grid-row: 1; }
  .tx-date { grid-column: 1; grid-row: 2; font-size: .8rem; }
  .tx-balance { grid-column: 2; grid-row: 2; font-size: .8rem; }
  .tx-acts { grid-column: 1 / -1; grid-row: 3; }
  .tx > .err { grid-column: 1 / -1; grid-row: 4; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Planche d'icônes : retirée de la mise en page sans attribut style en ligne (R8.4). */
.icon-sprite {
  position: absolute;
}

/* Page de confidentialité (R7.11) : texte long, autonome, sans script. */
.legal { max-width: 42rem; margin: 0 auto; padding: 2rem 16px 3rem; overflow-wrap: anywhere; }
.legal h1 { font-size: clamp(1.6rem, 6vw, 2.2rem); margin: .5rem 0 1rem; }
.legal h2 { font-size: 1.2rem; margin: 1.75rem 0 .5rem; }
.legal ul { list-style: disc; padding-left: 1.25rem; }

/* Aide repliable à côté d'un libellé (R2.12) : <details> natif, sans script. */
.label-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.help { display: contents; }
.help summary { list-style: none; cursor: pointer; width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); }
.help summary::-webkit-details-marker { display: none; }
.help summary:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.help p { flex-basis: 100%; margin: .25rem 0 0; font-size: .9rem; color: var(--muted); }
