/* ==========================================================================
   KInvoice — feuille unique, sans dépendance ni CDN (CSP stricte).

   Règle d'espacement : chaque pile verticale est un conteneur `flex column`
   avec UN seul `gap` ; ses enfants n'ont aucune marge. Aucune marge n'est
   posée élément par élément.
   ========================================================================== */

/* --------------------------------------------------------------- polices */
/* Mona Sans, servie en local : la CSP interdit toute police distante. */
@font-face {
  font-family: 'Mona Sans';
  src: url('../fonts/mona-sans-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ------------------------------------------------------------- variables */
/* Palette : structure Pennylane (fond blanc, barre latérale foncée pleine hauteur),
   vert remplacé par le couple prune / corail. */
:root {
  --bg: #ffffff;
  --bg-2: #f7f5f7;
  --bg-3: #eeeaef;
  --surface: #ffffff;
  --surface-2: #fbfafb;

  --ink: #1a141c;
  --ink-2: #4f4654;
  --ink-3: #6f6575;
  --ink-4: #a097a5;

  /* Barre latérale */
  --nav: #2e1b33;
  --nav-2: #3c2442;
  --nav-ink: #efe8f0;
  --nav-ink-2: #b7a6bd;
  /* Ton plus clair pour la colonne des écrans publics : la lueur corail y éclaircit le fond,
     ce qui ferait passer --nav-ink-2 sous 4,5:1. */
  --nav-ink-3: #cdbcd2;
  --nav-edge: rgba(255, 255, 255, .1);

  /* Accent d'action.
     --accent : corail décoratif (jauges, graphiques, taches des illustrations).
     --accent-strong : fond des surfaces qui portent du texte blanc (ratio ≥ 4,5:1).
     --accent-text : corail lisible sur fond clair (liens, onglet actif, ratio ≥ 4,5:1). */
  --accent: #f0455f;
  --accent-strong: #d8304a;
  --accent-hover: #ba2740;
  --accent-press: #9e1f35;
  --accent-text: #c92741;
  --accent-tint: #ffecef;
  --accent-ink: #9d1f33;

  /* États */
  --ok: #0e8a5f;
  --ok-bg: #e3f6ee;
  --ok-fg: #0a6a49;
  --warn: #a06a00;
  --warn-bg: #fdf1dc;
  --warn-fg: #7a4f00;
  --bad: #c0392b;
  --bad-bg: #fcebe9;
  --bad-fg: #9b2a20;
  --info-bg: #ece9fa;
  --info-fg: #4b3b9c;

  --edge: rgba(26, 20, 28, .09);
  --edge-2: rgba(26, 20, 28, .15);
  --edge-3: rgba(26, 20, 28, .26);

  --r-ctl: 8px;
  --r-tile: 10px;
  --r-card: 12px;
  --r-frame: 16px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(26, 20, 28, .05);
  --shadow-2: 0 1px 2px rgba(26, 20, 28, .05), 0 6px 16px -6px rgba(26, 20, 28, .1), 0 22px 44px -20px rgba(26, 20, 28, .16);
  --shadow-3: 0 2px 4px rgba(26, 20, 28, .05), 0 18px 36px -12px rgba(26, 20, 28, .16), 0 56px 110px -34px rgba(26, 20, 28, .24);

  --font-sans: 'Mona Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, 'DejaVu Sans Mono', monospace;

  --gap: 20px;
  --gap-sm: 10px;
  --gap-xs: 6px;
  --side-w: 256px;
  --page-max: 1360px;
  --tap: 44px;
}

/* ------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 15px/1.55 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, dl, dd, dt, figure, ul, ol, fieldset, legend { margin: 0; padding: 0; }
ul, ol { list-style: none; }
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -.012em; line-height: 1.25; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
.card__head > a:not(.btn), .table td a, .linkcard__text a { color: var(--accent-text); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

code {
  font: .92em/1.45 var(--font-mono);
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 6px;
  overflow-wrap: anywhere;
}

.muted { color: var(--ink-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 650; }

.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;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   Coquille : barre latérale + colonne de contenu
   ========================================================================== */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  /* La colonne foncée court sur toute la hauteur, même si la page est longue. */
  background: linear-gradient(to right, var(--nav) 0 var(--side-w), var(--bg) var(--side-w));
}

.side {
  grid-column: 1;
  background: var(--nav);
  color: var(--nav-ink);
  border-right: 1px solid transparent;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.side > * { margin: 0; }

.side__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
  padding: 14px 16px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.02em;
  color: inherit;
  text-decoration: none;
}
.side .brand { color: #fff; }
.brand__mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-1);
}
.brand--lg { font-size: 22px; }
.brand--lg .brand__mark { width: 38px; height: 38px; border-radius: 11px; font-size: 19px; }

.side__nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 12px 16px;
  flex: 1 1 auto;
}
.side__nav > * { margin: 0; }

.side__group { display: flex; flex-direction: column; gap: 2px; }
.side__group > * { margin: 0; }

.side__label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--nav-ink-2);
  padding: 0 10px 5px;
}

.side__link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: var(--tap);
  padding: 0 11px;
  border-radius: var(--r-ctl);
  color: var(--nav-ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}
.side__link:hover { background: var(--nav-2); color: #fff; }
.side__link.is-active {
  background: var(--accent-strong);
  color: #fff;
  font-weight: 650;
}
.side__link.is-active .ico { color: #fff; }
.side__link.is-active:hover { background: var(--accent-hover); color: #fff; }
.side__link .ico { flex: 0 0 auto; color: var(--nav-ink-2); }
.side__link:hover .ico { color: #fff; }
.side__link span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side__count {
  margin-left: auto;
  flex: 0 0 auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--bad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.side__count--quiet { background: rgba(255, 255, 255, .16); color: #fff; }
.side__link.is-active .side__count { background: rgba(255, 255, 255, .24); color: #fff; }

.side__foot {
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
  padding: 12px;
  border-top: 1px solid var(--nav-edge);
}
.side__foot > * { margin: 0; }

.side__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  min-width: 0;
}
.side__user > * { margin: 0; }
.avatar {
  display: grid; place-items: center;
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: var(--r-pill);
  background: var(--accent-strong);
  color: #fff;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
}
.side__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.side__who > * { margin: 0; }
.side__who b { font-size: 13px; font-weight: 650; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__who span { font-size: 12px; color: var(--nav-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side__close { display: none; }

/* ------------------------------------------------------------- colonne */
.main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.main > * { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--edge);
}
.topbar__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  width: 100%;
  min-height: 64px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}
.topbar__inner > * { margin: 0; }
.topbar__burger { display: none; }

/* Recherche globale : volontairement large et toujours visible. */
.search {
  flex: 1 1 420px;
  max-width: 560px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 2px 2px 2px 14px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.search > * { margin: 0; }
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.search .ico { flex: 0 0 auto; color: var(--ink-4); }
.search input[type=search] {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: var(--tap);
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  padding: 0;
  outline: none;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}
.search input[type=search]:focus, .search input[type=search]:hover { border: 0; box-shadow: none; }
.search input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--ink-4); }
.search button {
  flex: 0 0 auto;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 12px;
  min-height: var(--tap);
  border-radius: 6px;
}
.search button:hover { background: var(--bg-2); color: var(--accent-text); }

.topbar__tools { margin-left: auto; display: flex; align-items: center; gap: var(--gap-xs); }

.iconbtn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--tap); height: var(--tap);
  flex: 0 0 auto;
  border-radius: var(--r-ctl);
  border: 1px solid transparent;
  background: none;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
}
.iconbtn:hover { background: var(--bg-2); color: var(--ink); }
.iconbtn.is-active { background: var(--surface); border-color: var(--edge-2); color: var(--accent-text); }
.iconbtn__count {
  position: absolute; top: 5px; right: 3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--bad); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
}

/* Sélecteur de boutique */
.shopswitch { display: flex; align-items: center; gap: 6px; }
.shopswitch select {
  height: var(--tap);
  min-height: var(--tap);
  width: auto;
  max-width: 220px;
  padding: 0 34px 0 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ------------------------------------------------------------- page */
.page {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}
.page > * { margin: 0; }

.page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap);
}
.page__head > * { margin: 0; }
.page__heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 320px; }
.page__heading > * { margin: 0; }
.page__title { font-size: 27px; letter-spacing: -.025em; }
.page__lead { color: var(--ink-3); font-size: 14px; max-width: 76ch; }

.crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.crumb a { color: var(--ink-3); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; }
.crumb a:hover { color: var(--accent-text); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); }
.actions > * { margin: 0; }
.actions form { margin: 0; display: contents; }

/* ------------------------------------------------------------- boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn--primary { background: var(--accent-strong); color: #fff; box-shadow: var(--shadow-1); }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--primary:active { background: var(--accent-press); }
.btn--ghost { background: var(--surface); border-color: var(--edge-2); color: var(--ink); box-shadow: var(--shadow-1); }
.btn--ghost:hover { background: var(--bg-2); color: var(--ink); border-color: var(--edge-3); }
.btn--quiet { background: none; color: var(--ink-2); }
.btn--quiet:hover { background: var(--bg-2); color: var(--ink); }
.side .btn--quiet { color: var(--nav-ink-2); justify-content: flex-start; }
.side .btn--quiet:hover { background: var(--nav-2); color: #fff; }
.btn--danger { background: var(--bad); color: #fff; }
.btn--danger:hover { background: var(--bad-fg); color: #fff; }
.btn--link { background: none; color: var(--ink-3); padding: 0 6px; font-weight: 500; }
.btn--link:hover { color: var(--accent-text); text-decoration: underline; }
.btn--sm { min-height: var(--tap); padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn .ico { flex: 0 0 auto; }

/* ------------------------------------------------------------- cartes */
.card {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}
.card > * { margin: 0; }
.card--flush { padding: 0; gap: 0; overflow: hidden; }
.card--flush > .card__head { padding: var(--gap); }
.card--flush > .table-wrap, .card--flush > .empty, .card--flush > .card__foot { border-top: 1px solid var(--edge); }
.card--flush > .card__head + .table-wrap, .card--flush > .card__head + .empty { border-top: 1px solid var(--edge); }
.card--narrow { max-width: 620px; }
.card--tint { background: var(--accent-tint); border-color: rgba(240, 69, 95, .2); }
.card--warn { background: var(--warn-bg); border-color: rgba(160, 106, 0, .25); }
.card--bad { background: var(--bad-bg); border-color: rgba(192, 57, 43, .25); }

.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-sm);
}
.card__head > * { margin: 0; }
.card__title { font-size: 16px; }
.card__sub { font-size: 13px; color: var(--ink-3); }
.card__head > a:not(.btn) {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: var(--tap); font-size: 13px; font-weight: 600; text-decoration: none;
}
.card__head > a:not(.btn):hover { text-decoration: underline; }
.card__help { font-size: 13px; color: var(--ink-3); }
.card--flush > .card__help { padding: 0 var(--gap) var(--gap); }
.card__foot { padding: 12px var(--gap); font-size: 13px; color: var(--ink-3); background: var(--surface-2); }

.grid { display: grid; gap: var(--gap); min-width: 0; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }

/* ------------------------------------------------------------- tuiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 212px), 1fr));
  gap: var(--gap-sm);
}
.tile {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-tile);
  box-shadow: var(--shadow-1);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.tile > * { margin: 0; }
.tile__label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3);
}
.tile__value { font-size: 25px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile__sub { font-size: 12.5px; color: var(--ink-3); }
a.tile:hover { border-color: var(--edge-3); box-shadow: var(--shadow-2); color: inherit; }
.tile--ok .tile__value { color: var(--ok-fg); }
.tile--warn .tile__value { color: var(--warn-fg); }
.tile--bad .tile__value { color: var(--bad-fg); }

/* Balance âgée : tuiles avec filet de couleur */
.aging { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: var(--gap-sm); }
.aging .tile { border-top: 3px solid var(--edge-2); }
.aging .tile--a1 { border-top-color: #e8b931; }
.aging .tile--a2 { border-top-color: #e0802f; }
.aging .tile--a3 { border-top-color: #d8503c; }
.aging .tile--a4 { border-top-color: var(--bad); }

/* ------------------------------------------------------------- listes de définitions */
.defs { display: flex; flex-direction: column; }
.defs > * { margin: 0; }
.defs__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap-sm);
  padding: 9px 0;
}
.defs__row:first-child { padding-top: 0; }
.defs__row:last-child { padding-bottom: 0; }
.defs__row:not(:last-child) { border-bottom: 1px solid var(--edge); }
.defs dt { color: var(--ink-3); font-size: 13.5px; flex: 0 0 auto; }
.defs dd { text-align: right; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--gap); }
.stats > * { margin: 0; }
.stats__item { display: flex; flex-direction: column; gap: 2px; }
.stats__item > * { margin: 0; }
.stats dt { color: var(--ink-3); font-size: 13px; }
.stats dd { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ------------------------------------------------------------- filtres */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--gap-sm);
}
.filters > * { margin: 0; }
.filters .field { flex: 0 1 180px; min-width: 0; gap: 4px; }
.filters .field--grow { flex: 1 1 280px; }
.filters .field__label { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
.filters input, .filters select { background: var(--surface); }
.filters__actions { display: flex; gap: var(--gap-sm); flex-wrap: wrap; }

/* ------------------------------------------------------------- onglets */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-bottom: 1px solid var(--edge-2);
  scrollbar-width: thin;
}
.tabs > * { margin: 0; }
.tabs__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap);
  padding: 0 12px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__item:hover { color: var(--ink); }
.tabs__item.is-active { border-bottom-color: var(--accent-strong); font-weight: 650; }
.tabs__count {
  min-width: 20px; height: 19px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--bg-3); color: var(--ink-3);
  font-size: 11px; font-weight: 700; line-height: 19px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.tabs__item.is-active .tabs__count { background: var(--accent-tint); color: var(--accent-ink); }
.tabs__item.is-active { color: var(--accent-ink); }
.tabs__item.is-active { color: var(--accent-ink); }
.tabs__count--bad { background: var(--bad-bg); color: var(--bad-fg); }

/* ------------------------------------------------------------- tableaux */
/* `position: relative` : sans bloc conteneur ici, un enfant en position absolue — un
   libellé `.sr-only` dans l'en-tête de la dernière colonne, par exemple — échappe au
   découpage du conteneur et allonge la page entière. Mesuré : 1517 px pour 1280. */
.table-wrap { position: relative; overflow-x: auto; overscroll-behavior-x: contain; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-3);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--edge-2);
  white-space: nowrap;
}
.table td { padding: 11px 12px; vertical-align: middle; border-bottom: 1px solid var(--edge); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: var(--gap); }
.table th:last-child, .table td:last-child { padding-right: var(--gap); }
.table td a { text-decoration: none; font-weight: 600; }
.table td a:hover { text-decoration: underline; }
.table .num { text-align: right; }
.cell-strong { font-weight: 650; }
.cell-sub { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.th-sort:hover, .th-sort.is-active { color: var(--accent-text); }
.row-section td { background: var(--bg-2); font-weight: 650; }
.late { color: var(--bad-fg); font-weight: 650; font-size: 12px; white-space: nowrap; }
sup { font-size: 10px; }

/* ------------------------------------------------------------- badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  background: var(--bg-3);
  color: var(--ink-2);
}
.badge--ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge--error { background: var(--bad-bg); color: var(--bad-fg); }
.badge--warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge--info { background: var(--info-bg); color: var(--info-fg); }
.badge--muted { background: var(--bg-3); color: var(--ink-3); }

/* Pourquoi une facture n'est pas partie en facture électronique : une pastille d'état, du
   même vocabulaire que les statuts voisins. En texte coloré, la phrase se lisait comme un
   lien (les noms de clients de la même ligne sont rouges eux aussi) et promettait un clic
   qui n'existe pas. Seule différence avec une pastille ordinaire : le libellé peut passer à
   la ligne, la colonne étant étroite. */
.emotif {
  max-width: 22ch;
  white-space: normal;
  line-height: 1.3;
  text-align: left;
}

.state { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.state__dot { flex: 0 0 auto; }

/* ------------------------------------------------------------- états vides */
.empty {
  padding: 44px var(--gap) 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  color: var(--ink-3);
}
.empty > * { margin: 0; }
.empty .ico { color: var(--ink-4); }
.empty b { color: var(--ink); font-weight: 650; font-size: 16px; }
.empty p { font-size: 13.5px; max-width: 48ch; }
.empty .actions { justify-content: center; padding-top: 4px; }
/* Illustration : dessin au trait sur une tache corail, comme sur les écrans vides modernes. */
.illus { display: block; max-width: 100%; height: auto; }
.empty .illus { margin-bottom: 2px; }
@media (max-width: 560px) { .empty .illus { width: 150px; height: auto; } }

/* ------------------------------------------------------------- formulaires */
.form { display: flex; flex-direction: column; gap: var(--gap); }
.form > * { margin: 0; }
.form--tight { gap: var(--gap-sm); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > * { margin: 0; }
.field__label { font-weight: 600; font-size: 13px; }
.field__label .muted { font-weight: 400; }
.field__help { font-size: 12.5px; color: var(--ink-3); }

input[type=text], input[type=email], input[type=tel], input[type=url], input[type=password],
input[type=search], input[type=number], input[type=date], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0 13px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
}
textarea { padding: 11px 13px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--edge-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
input:disabled, select:disabled, textarea:disabled { background: var(--bg-2); color: var(--ink-3); cursor: not-allowed; }
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236a665e'%3E%3Cpath d='M4.2 6.3a1 1 0 0 1 1.4 0L8 8.7l2.4-2.4a1 1 0 1 1 1.4 1.4l-3.1 3.1a1 1 0 0 1-1.4 0L4.2 7.7a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 16px;
}
input[type=file] { min-height: var(--tap); padding: 10px 0; border: 0; background: none; max-width: 100%; }
input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--accent); }

.check-field { display: flex; align-items: center; gap: var(--gap-sm); min-height: var(--tap); }
.check-field > * { margin: 0; }
.check-field input { flex: 0 0 auto; }
.check-field span { font-size: 14px; }

.fields-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: var(--gap); align-items: start; }
.fields-row > * { margin: 0; }
.fields-row--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); }
.inline-form > * { margin: 0; }
.inline-form select, .inline-form input { width: auto; flex: 1 1 180px; min-width: 0; }
.inline-form .field--inline { flex: 0 0 auto; gap: 3px; }
.inline-form .field--inline .field__label { font-size: 11.5px; color: var(--ink-3); }
.inline-form__unit { font-size: 13px; color: var(--ink-3); align-self: flex-end; padding-bottom: 12px; }

/* Groupes d'un formulaire long : un intertitre et un filet, pas un cadre dans la carte.
   Le <legend> est flotté : sinon le navigateur le dessine à cheval sur le filet du <fieldset>. */
.fieldset { display: block; border: 0; padding: 0; min-width: 0; }
.fieldset + .fieldset { margin-top: 4px; padding-top: var(--gap); border-top: 1px solid var(--edge); }
.fieldset__legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fieldset__body { clear: both; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.fieldset__body > * { margin: 0; }

/* Champ piège : hors écran, jamais atteint au clavier. */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ------------------------------------------------------------- messages */
.flash {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-sm);
  padding: 12px 16px;
  border-radius: var(--r-ctl);
  border: 1px solid transparent;
  font-size: 14px;
}
.flash > * { margin: 0; }
.flash .ico { flex: 0 0 auto; }
.flash__text { flex: 1 1 260px; min-width: 0; }
.flash--success { background: var(--ok-bg); color: var(--ok-fg); border-color: rgba(14, 138, 95, .22); }
.flash--error { background: var(--bad-bg); color: var(--bad-fg); border-color: rgba(192, 57, 43, .22); }
.flash--warn { background: var(--warn-bg); color: var(--warn-fg); border-color: rgba(160, 106, 0, .25); }
.flash--info { background: var(--info-bg); color: var(--info-fg); border-color: rgba(75, 59, 156, .2); }
.flash a:not(.btn) { color: inherit; font-weight: 650; text-decoration: underline; }

.secret code {
  display: block;
  font-size: 15px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  user-select: all;
}

/* ------------------------------------------------------------- état de liaison */
.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--gap-sm); }
.linkcard {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--edge);
  border-radius: var(--r-tile);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.linkcard > * { margin: 0; }
.linkcard__dot {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-pill);
  background: var(--bg-3); color: var(--ink-3);
}
.linkcard--ok .linkcard__dot { background: var(--ok-bg); color: var(--ok-fg); }
a.linkcard .linkcard__dot { background: var(--accent-tint); color: var(--accent-ink); }
.linkcard--warn .linkcard__dot { background: var(--warn-bg); color: var(--warn-fg); }
.linkcard--bad .linkcard__dot { background: var(--bad-bg); color: var(--bad-fg); }
.linkcard__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.linkcard__body > * { margin: 0; }
.linkcard__title { font-size: 14px; font-weight: 650; }
a.linkcard { color: inherit; text-decoration: none; }
a.linkcard:hover { border-color: var(--edge-3); box-shadow: var(--shadow-2); color: inherit; }
a.linkcard:hover .linkcard__title { color: var(--accent-ink); }
a.tile:hover .tile__value { color: var(--accent-ink); }
.linkcard__text { font-size: 13px; color: var(--ink-3); }
.linkcard__text a { font-weight: 600; }
.linkcard__action { display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); font-size: 13px; font-weight: 650; color: var(--accent-text); text-decoration: none; }
.linkcard__action:hover { text-decoration: underline; }

/* ------------------------------------------------------------- jauge d'offre */
.quota { display: flex; flex-direction: column; gap: var(--gap-sm); }
.quota > * { margin: 0; }
.quota__bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--bg-3);
  overflow: hidden;
}
.quota__bar::-webkit-progress-bar { background: var(--bg-3); border-radius: var(--r-pill); }
.quota__bar::-webkit-progress-value { background: var(--accent); border-radius: var(--r-pill); }
.quota__bar::-moz-progress-bar { background: var(--accent); border-radius: var(--r-pill); }
.quota__bar.is-near::-webkit-progress-value { background: #e0a000; }
.quota__bar.is-near::-moz-progress-bar { background: #e0a000; }
.quota__bar.is-over::-webkit-progress-value { background: var(--bad); }
.quota__bar.is-over::-moz-progress-bar { background: var(--bad); }
.quota__legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--gap-sm); font-size: 13px; color: var(--ink-3); }
.quota__legend > * { margin: 0; }
.quota__legend b { color: var(--ink); font-weight: 650; }
.quota--row { display: flex; flex-direction: column; gap: 5px; min-width: 170px; }
.quota--row > * { margin: 0; }
.quota--row .quota__bar { height: 7px; }
.quota--row span { font-size: 12px; }

/* ------------------------------------------------------------- alertes */
.alerts {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 14px var(--gap);
  border-left: 3px solid transparent;
}
.alert-item:not(:last-child) { border-bottom: 1px solid var(--edge); }
.alert-item--high { border-left-color: var(--bad); }
.alert-item--medium { border-left-color: #e0802f; }
.alert-item.is-unread { background: var(--surface-2); }
.alert-item__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.alert-item__body > * { margin: 0; }
.alert-item__who { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); font-weight: 650; font-size: 14px; }
.alert-item__who a { text-decoration: none; }
.alert-item__title { font-size: 14px; }
.alert-item.is-unread .alert-item__title { font-weight: 650; }
.alert-item__meta { font-size: 12.5px; color: var(--ink-3); }
.alert-item form { margin: 0; flex: 0 0 auto; }

/* ------------------------------------------------------------- contrôles de rapprochement */
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); gap: var(--gap-sm); }
.check {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-tile);
  box-shadow: var(--shadow-1);
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.check > * { margin: 0; }
.check:hover { border-color: var(--edge-3); color: inherit; }
.check.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-1); }
.check__title { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.check__count { font-size: 23px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.check__amount { font-size: 12px; color: var(--ink-3); }
.check.is-clean .check__count { color: var(--ok-fg); }

/* ------------------------------------------------------------- graphique */
.chart { position: relative; height: 320px; }

/* ------------------------------------------------------------- pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); flex-wrap: wrap; }
.pager > * { margin: 0; }
.pager__info { font-size: 13px; color: var(--ink-3); }
.pager__nav { display: flex; gap: var(--gap-sm); }

/* Lignes par page */
.pagesize { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-xs); font-size: 13px; color: var(--ink-3); }
.pagesize > * { margin: 0; }
.pagesize__item {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap); padding: 0 10px;
  border: 1px solid var(--edge-2); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 600;
}
.pagesize__item:hover { background: var(--bg-2); color: var(--ink); }
.pagesize__item.is-active { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

/* ------------------------------------------------------------- document (lignes, totaux) */
.doc-lines { display: flex; flex-direction: column; }
.doc-lines > * { margin: 0; }
.doc-line {
  display: grid;
  grid-template-columns: minmax(180px, 2.2fr) minmax(160px, 2fr) repeat(5, minmax(72px, .8fr)) minmax(94px, .9fr) auto;
  gap: var(--gap-sm);
  align-items: end;
  padding: 12px var(--gap);
}
.doc-line > * { margin: 0; min-width: 0; }
.doc-line:not(:last-child) { border-bottom: 1px solid var(--edge); }
.doc-line--section { grid-template-columns: 1fr auto; background: var(--bg-2); }
.doc-line__desc textarea { min-height: var(--tap); resize: vertical; }
.doc-line__total {
  font-variant-numeric: tabular-nums; text-align: right; font-weight: 650;
  min-height: var(--tap); display: flex; align-items: center; justify-content: flex-end;
}
.doc-line__remove { min-height: var(--tap); }
/* Une croix partout : l'intitulé reste lisible par un lecteur d'écran, et la colonne de
   retrait cesse d'écraser le total de la ligne. */
.doc-line__remove svg { flex: 0 0 auto; }
.doc-lines__foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
  gap: var(--gap); padding: var(--gap); border-top: 1px solid var(--edge); background: var(--surface-2);
}
.doc-lines__foot > * { margin: 0; }
.doc-totals { display: flex; flex-direction: column; gap: 5px; min-width: min(100%, 280px); }
.doc-totals > * { margin: 0; }
.doc-totals > div { display: flex; justify-content: space-between; gap: var(--gap); }
.doc-totals dt, .doc-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.doc-totals dt { color: var(--ink-3); }
.doc-totals__grand { font-weight: 700; font-size: 17px; padding-top: 6px; border-top: 1px solid var(--edge-2); }
.doc-totals__grand dt { color: var(--ink); }
.doc-totals--pad { padding: var(--gap); margin-left: auto; max-width: 380px; }

.mentions { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); font-size: 13px; }
.mentions > li { margin: 0; }

.inline-form .input--xs, .input--xs { width: 90px; flex: 0 0 auto; min-width: 0; }
.pay-form { align-items: flex-end; }
.pay-form .field { flex: 0 1 190px; }

details > summary { list-style: none; cursor: pointer; }
/* Confirmation en deux temps : le bouton destructeur n'apparaît qu'après ouverture. */
.confirm { display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-sm); }
.confirm > * { margin: 0; }
.confirm__body {
  align-self: stretch;
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-sm);
  padding: 14px 16px; border: 1px solid var(--bad-bg); border-radius: var(--r-ctl);
  background: var(--bad-bg); color: var(--bad-fg); font-size: 13.5px;
}
.confirm__body > * { margin: 0; }
.confirm__body strong { font-weight: 700; }
details > summary::-webkit-details-marker { display: none; }
.send-mail { padding-top: var(--gap); }

/* ------------------------------------------------------------- icônes */
.ico { display: inline-block; vertical-align: -.15em; flex: 0 0 auto; }

/* ==========================================================================
   Écrans publics (connexion, 2FA, inscription, secours de compte)
   Écran scindé : colonne de marque sombre à gauche, formulaire à droite.
   ========================================================================== */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* ---------------------------------------------- colonne de marque */
.auth__aside {
  display: none;
  position: relative;
  overflow: hidden;
  padding: 40px clamp(32px, 3.2vw, 56px);
  color: var(--nav-ink);
  background:
    radial-gradient(620px 420px at 86% 4%, rgba(240, 69, 95, .3), transparent 62%),
    radial-gradient(520px 380px at 4% 96%, rgba(240, 69, 95, .14), transparent 60%),
    linear-gradient(158deg, #42284a 0%, var(--nav) 52%, #22121f 100%);
}
/* Le contenu reste dans une colonne de lecture et se centre : sans cela, sur un grand
   écran, la marque est collée en haut, le titre en bas, et la moitié droite est vide. */
.auth__aside > * { margin: 0; position: relative; z-index: 1; width: 100%; max-width: 32rem; margin-inline: auto; }
.auth__aside .brand { color: #fff; }

.auth__pitch { display: flex; flex-direction: column; gap: 16px; align-self: center; }
/* La marque fait partie du bloc : pas de logo orphelin en haut avec un vide dessous. */
.auth__pitch .brand { align-self: flex-start; margin-bottom: 14px; }
.auth__pitch > * { margin: 0; }
.auth__pitch-title {
  font-size: clamp(25px, 1.9vw, 31px);
  line-height: 1.15;
  letter-spacing: -.03em;
  font-weight: 700;
  color: #fff;
  text-wrap: balance;
}
.auth__pitch-lead { font-size: 15px; line-height: 1.55; color: var(--nav-ink-3); }

.auth__points { display: flex; flex-direction: column; }
.auth__points { gap: 12px; }
.auth__points > li { display: flex; align-items: flex-start; gap: 11px; font-size: 14px; line-height: 1.5; color: var(--nav-ink); }
.auth__point-dot {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 22px; height: 22px; margin-top: 1px;
  border-radius: var(--r-pill);
  background: var(--accent-strong);
  color: #fff;
}

.auth__art {
  position: absolute;
  right: -56px;
  bottom: 4px;
  width: 320px;
  height: auto;
  color: rgba(255, 255, 255, .17);
  z-index: 0;
  pointer-events: none;
}
@media (min-width: 1600px) { .auth__art { width: 360px; } }

/* ---------------------------------------------- colonne du formulaire */
.auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-width: 0;
  /* Fond légèrement teinté : sans lui, la carte blanche se perd sur du blanc. */
  background:
    radial-gradient(820px 460px at 50% -18%, var(--accent-tint), transparent 66%),
    var(--bg-2);
}

.auth__box {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-frame);
  box-shadow: var(--shadow-2);
  padding: 36px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.auth__box > * { margin: 0; }
.auth__box--wide { max-width: 500px; }
.auth__box--signup { max-width: 600px; }

.auth__head { display: flex; flex-direction: column; gap: 7px; }
.auth__head > * { margin: 0; }
/* La marque n'est répétée dans la carte que là où la colonne de gauche est absente. */
.auth__head .brand { display: none; }
/* Page de rebond Super PDP : pas de colonne de gauche, la marque reste dans la carte. */
.auth > .auth__main:only-child .auth__head .brand { display: inline-flex; }
.auth__title { font-size: 25px; letter-spacing: -.025em; }
.auth__lead { color: var(--ink-3); font-size: 14.5px; line-height: 1.55; }

.auth__alt {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px;
  font-size: 14px; padding-top: 2px; border-top: 1px solid var(--edge);
}
.auth__alt a, .auth__alt button {
  display: inline-block;
  padding: 12px 6px;
  line-height: 20px;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.totp { display: flex; flex-direction: column; align-items: center; gap: var(--gap-sm); }
.totp > * { margin: 0; }
.totp__qr {
  width: 200px; height: 200px; max-width: 100%;
  border-radius: var(--r-ctl);
  border: 1px solid var(--edge-2);
  background: #fff;
  padding: 8px;
}
.totp__secret { font-size: 13px; color: var(--ink-3); text-align: center; }

/* Liste numérotée des étapes, sur les écrans qui en montrent une. */
.steps { display: flex; flex-direction: column; gap: 12px; }
.steps > li { display: flex; align-items: flex-start; gap: 12px; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.steps__n {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 24px; height: 24px;
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
}

/* --------------------------------------------------------------------------
   Mise en route : les étapes à franchir avant de facturer.
   Une seule liste encadrée, un médaillon numéroté par étape, des séparateurs
   entre elles. L'espacement appartient aux conteneurs (.setup, .setup__body) :
   aucune marge posée sur les enfants.
   -------------------------------------------------------------------------- */
.setup__head { gap: var(--gap-sm); }

.setup {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.setup > * { margin: 0; }

.setup__step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  padding: var(--gap);
  min-width: 0;
}
.setup__step:not(:last-child) { border-bottom: 1px solid var(--edge); }

.setup__num {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: var(--r-pill);
  background: var(--accent-strong);
  color: #fff;
  font-size: 14px; font-weight: 700;
  line-height: 1;
}
.setup__step.is-done .setup__num { background: var(--ok); }
.setup__step.is-blocked .setup__num { background: var(--bg-3); color: var(--ink-3); }
.setup__num svg { display: block; }

.setup__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  /* Le médaillon mesure 30 px, le titre 20 px de hauteur de ligne : on recentre. */
  padding-top: 4px;
}
.setup__body > * { margin: 0; }
.setup__title { font-size: 15.5px; font-weight: 600; }
.setup__text { font-size: 14px; color: var(--ink-3); max-width: 76ch; }

/* Clé, secret, adresse : sur un large écran, la valeur alignée à droite se retrouve à un
   mètre de son libellé. Ici on garde les deux côte à côte, à gauche, sur une mesure courte. */
.setup__body .defs { max-width: 640px; }
.setup__body .defs__row { gap: 20px; justify-content: flex-start; }
.setup__body .defs dt { flex: 0 0 180px; }
.setup__body .defs dd { flex: 1 1 auto; text-align: left; }
@media (max-width: 599px) {
  .setup__body .defs dt { flex: 1 1 auto; }
}

/* Le diagnostic est une carte dans une carte : fond légèrement teinté, pas d'ombre. */
.setup__diag { background: var(--surface-2); box-shadow: none; }
.setup__diag .card__foot { background: var(--bg-2); }
.setup__diag-actions { padding: 0 var(--gap) var(--gap); background: var(--bg-2); }

@media (max-width: 599px) {
  .setup__step { gap: 12px; padding: var(--gap-sm); }
  .setup__num { width: 26px; height: 26px; font-size: 13px; }
}

@media (min-width: 1024px) {
  .auth { grid-template-columns: minmax(0, 1.05fr) minmax(480px, 1fr); }
  /* Le formulaire d'inscription est plus large : sa colonne l'est aussi. */
  .auth:has(.auth__box--signup) { grid-template-columns: minmax(0, 1fr) minmax(560px, 1.05fr); }
  /* Collée en haut et haute d'un écran : sur un formulaire long (inscription), la colonne
     ne doit pas s'étirer à la hauteur du document, sinon le titre part sous la ligne de flottaison. */
  .auth__aside {
    display: grid;
    grid-template-rows: 1fr;
    gap: 28px;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
  }
  .auth__main { padding: 48px; }
}

@media (min-width: 1600px) {
  .auth { grid-template-columns: minmax(0, 1fr) minmax(560px, .82fr); }
}

/* Sans la colonne de gauche, la carte reprend la marque et un peu plus d'air. */
@media (max-width: 1023px) {
  .auth__head .brand { display: inline-flex; }
  .auth__box { gap: 18px; }
}

/* ==========================================================================
   Adaptation aux écrans
   ========================================================================== */

/* Barre latérale en tiroir sous 1080 px. Ouverture par ancre (#menu) :
   aucun script requis, donc jamais cassée. */
@media (max-width: 1079px) {
  /* Le tiroir est hors écran : plus de bande foncée sur la gauche de la page. */
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--bg); }
  .main { grid-column: 1; }

  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 60;
    height: 100dvh;
    box-shadow: var(--shadow-3);
    transform: translateX(-102%);
    transition: transform .18s ease;
    border-right: 1px solid var(--edge-2);
  }
  .side:target { transform: none; }
  /* Voile : couvre la page quand le tiroir est ouvert. */
  .side:target::after {
    content: '';
    position: fixed;
    inset: 0;
    left: min(300px, 86vw);
    background: rgba(18, 17, 15, .34);
  }
  .side__close {
    display: inline-grid;
    place-items: center;
    width: var(--tap); height: var(--tap);
    border-radius: var(--r-ctl);
    color: var(--ink-2);
    text-decoration: none;
  }
  .side__close { color: var(--nav-ink); }
  .side__close:hover { background: var(--nav-2); color: #fff; }
  .topbar__burger {
    display: inline-grid;
    place-items: center;
    width: var(--tap); height: var(--tap);
    flex: 0 0 auto;
    border-radius: var(--r-ctl);
    border: 1px solid var(--edge-2);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
  }
  .topbar__burger:hover { background: var(--bg-2); }
  .topbar__inner { padding: 10px 16px; }
  .page { padding: 20px 16px 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}

@media (max-width: 860px) {
  .shopswitch { display: none; }
  .page__title { font-size: 23px; }
  .chart { height: 260px; }
  .doc-line { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .doc-line__label, .doc-line__desc { grid-column: 1 / -1; }
  .doc-line__total { grid-column: span 3; }
  .doc-line--section { grid-template-columns: 1fr auto; }
  .doc-line--section .doc-line__label { grid-column: auto; }
}

/* Tableaux en cartes sur mobile et tablette portrait : une ligne = un bloc étiqueté. */
@media (max-width: 800px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr { display: flex; flex-direction: column; gap: 7px; padding: 14px var(--gap); }
  .table tbody tr:not(:last-child) { border-bottom: 1px solid var(--edge); }
  .table tbody tr td { border-bottom: 0; }
  .table tbody tr:hover td { background: none; }
  .table td {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--gap); padding: 0 !important; text-align: right;
  }
  .table td::before {
    content: attr(data-label);
    color: var(--ink-3); font-weight: 500; font-size: 12.5px;
    text-align: left; flex: 0 0 auto;
  }
  .table td.num { text-align: right; }
  .table td a, .table td .badge { display: inline-flex; align-items: center; min-height: var(--tap); }
  .table td .inline-form { justify-content: flex-end; }
  .filters .field { flex: 1 1 150px; }
  .alert-item { flex-direction: column; align-items: stretch; }
  .alert-item__who a { display: inline-flex; align-items: center; min-height: var(--tap); }
  .crumb a { min-height: var(--tap); }
  .defs__row { flex-direction: column; gap: 2px; }
  .defs dd { text-align: left; }
}

@media (max-width: 680px) {
  /* Une seule ligne : loupe + champ + cloche. Le bouton « Rechercher » laisse la place,
     la touche Entrée valide le formulaire. */
  .search { flex: 1 1 auto; padding-right: 10px; }
  .search button { display: none; }
}

@media (max-width: 560px) {
  :root { --gap: 16px; }
  /* Garde-fou : un libellé long ne doit jamais pousser la page hors de l'écran. */
  .btn { white-space: normal; text-align: center; padding: 8px 14px; }
  .actions { align-items: stretch; }
  .page__title { font-size: 21px; }
  .auth__box { padding: 24px 20px; border-radius: var(--r-card); }
  .topbar__inner { padding: 8px 12px; gap: 8px; }
  .search { min-height: 44px; padding-left: 12px; }
  .doc-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-line__total { grid-column: span 1; }
  .empty { padding: 32px 16px; }
}

/* Paysage court (ex. 667x375) : la barre du haut ne doit pas manger l'écran. */
@media (max-height: 460px) and (orientation: landscape) {
  .topbar { position: static; }
  .side { height: 100dvh; }
}

@media print {
  .side, .topbar, .actions, .filters, .tabs { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* Rappel de mise en route sur le tableau de bord : le texte à gauche, l'action à droite,
   empilés tant que la place manque. */
.setup__call { flex-direction: row; align-items: center; flex-wrap: wrap; gap: var(--gap); }
.setup__call-body { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; min-width: 0; }
.setup__call-body > * { margin: 0; }

/* --------------------------------------------------------------------------
   Catalogue : prestations habituelles et unités. Une seule liste, un seul
   enregistrement — pas un bouton par ligne. L'espacement appartient aux
   conteneurs (.cat__list, .cat__row), jamais aux champs.
   -------------------------------------------------------------------------- */
.cat, .cat__new { display: flex; flex-direction: column; gap: var(--gap); }
.cat > *, .cat__new > * { margin: 0; }

.cat__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }

/* Une ligne du catalogue et l'en-tête de la liste partagent exactement la même grille :
   c'est la seule façon d'aligner les intitulés sur les champs qu'ils nomment. */
.cat__row {
  display: grid;
  gap: var(--gap-sm) var(--gap);
  align-items: start;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
}
.cat__row > * { margin: 0; }
.cat__row--unit { grid-template-columns: 90px minmax(0, 1fr); }

.cat__item { padding-bottom: 14px; border-bottom: 1px solid var(--edge); }
.cat__list > li:last-child { padding-bottom: 0; border-bottom: 0; }
.cat__drop { font-size: 13px; color: var(--ink-3); grid-column: 1 / -1; }

.cat__new { border-top: 1px solid var(--edge); padding-top: var(--gap); }
.cat__new-title { font-size: 14px; font-weight: 650; }

/* Les intitulés de colonne ne sont répétés sur chaque ligne que faute de place : dès que
   la grille est alignée, ils passent en tête de liste et les étiquettes de ligne ne
   restent que pour les lecteurs d'écran. Onze fois « Abrégé » à la suite, c'est du bruit. */
.cat__heads { display: none; }
.cat__heads > span { font-weight: 600; font-size: 13px; color: var(--ink-3); }

/* Deux seuils, parce que les deux listes n'ont pas la même largeur minimale : une unité
   tient en trois colonnes dès la tablette, une prestation en demande six et attend un
   écran large. Chaque liste passe en colonnes dès qu'elle y tient, pas avant.
   Dernière colonne à largeur fixe et non « auto » : vide dans l'en-tête, elle y
   mesurerait zéro et décalerait tous les intitulés d'un cran. */
@media (min-width: 700px) {
  .cat__row--unit { grid-template-columns: 130px minmax(0, 1fr) 96px; }
  .cat__heads.cat__row--unit { display: grid; }
  .cat__row--unit.cat__item { align-items: center; }
  .cat__row--unit .cat__drop { grid-column: auto; }
  .cat__list .cat__row--unit .field__label { display: none; }
}
@media (min-width: 900px) {
  .cat__row--service { grid-template-columns: minmax(0, 2fr) minmax(0, 2.4fr) 110px 120px 100px 96px; }
  .cat__heads.cat__row--service { display: grid; }
  .cat__row--service.cat__item { align-items: center; }
  .cat__row--service .cat__drop { grid-column: auto; }
  .cat__list .cat__row--service .field__label { display: none; }
}

/* --------------------------------------------------------------------------
   Éditeur de document : la page que recevra le client, modifiable en place.
   Les champs n'ont pas de cadre tant qu'on ne les survole pas — on lit un
   document, pas un formulaire — mais gardent un soulignement discret pour
   qu'aucun ne se cache. L'espacement appartient aux conteneurs.
   -------------------------------------------------------------------------- */
.docedit { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
.docedit > * { margin: 0; }
.docedit__side { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.docedit__side > * { margin: 0; }
.docedit__save { display: flex; flex-direction: column; gap: var(--gap-sm); }

.sheet {
  /* La mise en colonnes des lignes dépend de la largeur de la feuille, pas de celle de
     l'écran : avec le panneau de réglages à côté, une fenêtre large laisse une feuille
     étroite. C'est la feuille qu'il faut interroger.
     Un navigateur trop ancien pour les requêtes de conteneur (avant Safari 16) ignore la
     règle : les lignes restent empilées, lisibles et modifiables — rien ne casse. */
  container-type: inline-size;
  container-name: feuille;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-2);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: 26px;
  min-width: 0;
}
.sheet > * { margin: 0; }

/* Un champ « nu » : pas de cadre au repos, un fond et un cadre dès qu'on l'approche.
   Le soulignement permanent dit qu'il se saisit, sans quadriller la page. */
.field--bare > input, .field--bare > textarea, .sheet__party textarea, .sheet__notes textarea {
  border: 1px solid transparent;
  border-bottom-color: var(--edge-2);
  border-radius: var(--r-ctl) var(--r-ctl) 0 0;
  background: transparent;
  padding-left: 6px; padding-right: 6px;
}
.field--bare > input:hover, .field--bare > textarea:hover, .sheet__party textarea:hover, .sheet__notes textarea:hover {
  background: var(--bg-2);
  border-color: var(--edge-2);
}
.field--bare > input:focus, .field--bare > textarea:focus, .sheet__party textarea:focus, .sheet__notes textarea:focus {
  background: var(--surface);
  border-color: var(--accent-strong);
  border-radius: var(--r-ctl);
}
.field--bare .field__label { color: var(--ink-3); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }

/* En-tête : émetteur à gauche, nature et dates du document à droite. */
.sheet__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--gap); }
.sheet__head > * { margin: 0; }
.sheet__issuer { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; min-width: 0; font-size: 13.5px; color: var(--ink-2); }
.sheet__issuer > * { margin: 0; }
.sheet__logo { max-height: 56px; max-width: 200px; width: auto; margin-bottom: 8px; }
.sheet__issuer-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.sheet__legal { font-size: 12px; color: var(--ink-3); padding-top: 4px; }

.sheet__doc { display: flex; flex-direction: column; gap: 8px; flex: 0 1 280px; min-width: 0; align-items: flex-end; text-align: right; }
.sheet__doc > * { margin: 0; }
.sheet__doc .field { width: 100%; }
.sheet__title { font-size: 26px; font-weight: 700; color: var(--accent-text); line-height: 1.1; }
.sheet__number { font-size: 13.5px; color: var(--ink-3); }
.sheet__meta { display: flex; flex-wrap: wrap; gap: var(--gap-sm); width: 100%; }
.sheet__meta > * { margin: 0; flex: 1 1 130px; }
.sheet__service { width: 100%; }

/* Parties : livraison à gauche, destinataire à droite, comme sur le document. */
.sheet__parties { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
.sheet__parties > * { margin: 0; }
.sheet__party { display: flex; flex-direction: column; gap: var(--gap-sm); min-width: 0; }
.sheet__party > * { margin: 0; }
.sheet__party--client, .sheet__party--delivery { border: 1px solid var(--edge); border-radius: var(--r-tile); padding: 14px; }
.sheet__party--client { background: var(--surface-2); }
.sheet__party--delivery textarea { flex: 1 1 auto; }
.sheet__party-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--accent-text); }
.sheet__party-row { display: flex; flex-wrap: wrap; gap: var(--gap-sm); }
.sheet__party-row > * { margin: 0; flex: 1 1 120px; min-width: 0; }
.sheet__cp { flex: 0 1 110px; }
.sheet__pays { flex: 0 1 80px; }

.sheet__refs { display: flex; flex-wrap: wrap; gap: var(--gap); }
.sheet__refs > * { margin: 0; flex: 1 1 200px; min-width: 0; }

/* Les lignes : un tableau sur grand écran, des blocs empilés sur un téléphone. */
.sheet__lines { display: flex; flex-direction: column; border: 1px solid var(--edge); border-radius: var(--r-tile); overflow: hidden; }
.sheet__lines > * { margin: 0; }
.doc-lines__heads { display: none; }
.sheet__add { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); padding: 12px var(--gap); border-top: 1px solid var(--edge); background: var(--surface-2); }
.sheet__add > * { margin: 0; }
.sheet__pick { margin-left: auto; }

.sheet__bottom { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-items: start; }
.sheet__bottom > * { margin: 0; }
.sheet__pay { display: flex; flex-direction: column; gap: var(--gap-sm); min-width: 0; }
.sheet__pay > * { margin: 0; }
.sheet__block-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--accent-text); }
.sheet__pay-defs { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.sheet__pay-defs > * { margin: 0; }
.sheet__pay-defs > div { display: flex; gap: var(--gap-sm); }
.sheet__pay-defs dt { color: var(--ink-3); flex: 0 0 72px; }
.sheet__pay-defs dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.sheet__notes { display: flex; flex-direction: column; }
.sheet__mentions { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--edge); padding-top: 14px; }
.sheet__mentions > * { margin: 0; }
.sheet__mentions .sheet__block-title { color: var(--ink-3); }

@media (min-width: 760px) {
  .sheet { padding: 32px; }
  .sheet__parties { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
  .sheet__bottom { grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr); }
  .doc-totals { margin-left: auto; }
}

/* La colonne de réglages ne se met à côté que si la feuille garde de quoi afficher son
   tableau de lignes. En dessous, elle passe sous le document : mieux vaut une page large
   et des réglages plus bas qu'un document à l'étroit. */
@media (min-width: 1400px) {
  .docedit { grid-template-columns: minmax(0, 1fr) 280px; }
  .docedit__side { position: sticky; top: calc(var(--gap) + 56px); }
}

/* Le tableau des lignes, dès que la feuille est assez large : intitulés une seule fois en
   tête, et la description sous sa désignation comme sur le document imprimé — une colonne
   de moins, donc des colonnes de chiffres qui tiennent sans rogner. */
/* Dans la feuille, une ligne s'empile tant que le tableau ne tient pas : les règles
   générales de .doc-line visent la largeur de l'écran, qui ne dit rien de celle du
   document. */
.sheet .doc-line:not(.doc-line--section) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr));
}
.sheet .doc-line__label, .sheet .doc-line__desc { grid-column: 1 / -1; }
.sheet .doc-line__total { grid-column: 1 / -1; }

/* 730 px et non la somme des colonnes : la ligne porte aussi ses marges internes. */
@container feuille (min-width: 730px) {
  .sheet .doc-lines__heads,
  .sheet .doc-line:not(.doc-line--section) {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 56px 68px 88px 70px 66px 94px 44px;
    gap: 4px 8px;
    align-items: center;
  }
  .sheet .doc-lines__heads {
    padding: 10px var(--gap);
    background: var(--surface-2);
    border-bottom: 1px solid var(--edge);
  }
  .sheet .doc-lines__heads > span { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-3); }
  .sheet .doc-lines__heads > span.num { text-align: right; }
  /* Désignation et description l'une sous l'autre, dans la première colonne. */
  .sheet .doc-line__label { grid-column: 1; grid-row: 1; }
  .sheet .doc-line__desc { grid-column: 1; grid-row: 2; }
  /* Pas de grid-row ici : une ligne verrouillée sur sa rangée serait replacée avant
     les autres et le total remonterait en deuxième colonne. */
  .sheet .doc-line__total { grid-column: auto; }
  .sheet .doc-line__desc textarea { min-height: 34px; font-size: 13px; }
  /* Retirées de l'affichage, pas de l'accessibilité : chaque champ porte son aria-label. */
  .sheet .doc-lines .doc-line:not(.doc-line--section) .field__label { display: none; }
  .sheet .doc-line__remove { padding: 0; width: 44px; justify-content: center; }
}

/* ==========================================================================
   Réactivité de l'interface : chargement, messages, modale.
   Voir public/js/ux.js. Tout reste utilisable sans JavaScript, ces règles ne
   servent qu'à ce que le JS met à l'écran.
   ========================================================================== */

/* ------------------------------------------------- rangée d'onglets de section
   Elle tient sous la barre du haut, avant le titre : c'est de la navigation,
   pas du contenu. Le `gap` de `.page` suffit, aucune marge ici. */
.tabs--section {
  border-bottom: 1px solid var(--edge-2);
  font-size: 14.5px;
}
.tabs--inner { font-size: 14px; }

/* Les filtres rapides d'une liste ne sont PAS de la navigation : deux rangées d'onglets
   identiques l'une sous l'autre font perdre le fil. Des pastilles, donc, et pas de filet. */
.tabs--filters {
  border-bottom: 0;
  gap: 6px;
  padding-block-end: 2px;
}
.tabs--filters .tabs__item {
  /* La hauteur reste à 44 px : une pastille plus basse passerait sous la cible tactile. */
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 550;
}
.tabs--filters .tabs__item:hover { background: var(--bg-2); }
.tabs--filters .tabs__item.is-active {
  border-color: var(--accent-strong);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 650;
}
.tabs--filters .tabs__count { height: 18px; line-height: 18px; font-size: 10.5px; }

/* ------------------------------------------------- barre de chargement */
.topload {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 60;
  background: var(--accent-strong);
  transform: scaleX(0);
  transform-origin: 0 50%;
  opacity: 0;
  pointer-events: none;
}
.topload.is-running { opacity: 1; animation: kln-load 12s cubic-bezier(.1, .8, .2, 1) forwards; }
.topload.is-done { opacity: 0; transform: scaleX(1); transition: opacity .3s ease .06s, transform .2s ease; }
@keyframes kln-load {
  0% { transform: scaleX(0); }
  40% { transform: scaleX(.6); }
  100% { transform: scaleX(.94); }
}

/* ------------------------------------------------- bouton occupé
   La taille ne bouge pas : le libellé reste en place, un disque tourne devant. */
.btn.is-busy { position: relative; color: transparent; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentcolor;
  border-top-color: transparent;
  border-radius: 50%;
  color: #fff;
  animation: kln-spin .7s linear infinite;
}
.btn--ghost.is-busy::after, .btn--quiet.is-busy::after { color: var(--ink-2); }
@keyframes kln-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------- messages passagers */
.toasts {
  position: fixed;
  inset-block-end: 16px;
  inset-inline-end: 16px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  width: min(380px, calc(100vw - 32px));
  padding-block-end: env(safe-area-inset-bottom);
}
.toasts > * { margin: 0; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--gap-sm);
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--edge-2);
  border-inline-start: 3px solid var(--ink-3);
  border-radius: var(--r-ctl);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: 14px;
  line-height: 1.45;
  animation: kln-toast .18s ease-out;
}
.toast--success { border-inline-start-color: var(--ok); }
.toast--error { border-inline-start-color: var(--bad); }
.toast--warn { border-inline-start-color: var(--warn); }
.toast--info { border-inline-start-color: var(--info-fg); }
.toast.is-leaving { opacity: 0; transition: opacity .4s ease; }
.toast__close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-inline-start: auto;
  padding: 0;
  border: 0;
  border-radius: var(--r-ctl);
  background: none;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.toast__close:hover { background: var(--bg-2); color: var(--ink); }
@keyframes kln-toast { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------- écran ouvert par-dessus la page */
.modal {
  width: min(900px, calc(100vw - 32px));
  /* La feuille de style du navigateur borne un <dialog> à `calc(100% - 6px - 2em)` :
     sans cela, la boîte reste 36 px plus étroite que demandé. */
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--r-frame);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  color: var(--ink);
  overflow: hidden;
}
.modal::backdrop { background: rgba(26, 20, 28, .45); }
.modal__panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
}
.modal__panel > * { margin: 0; }
.modal__head {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 14px 16px 14px 20px;
  border-bottom: 1px solid var(--edge);
  background: var(--surface);
}
.modal__head > * { margin: 0; }
.modal__title { flex: 1 1 auto; font-size: 18px; }
.modal__body {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--gap) 20px calc(var(--gap) + env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal__body > * { margin: 0; }
.modal__lead { color: var(--ink-2); font-size: 14.5px; }
/* Deux colonnes sur un écran large n'ont pas de sens dans une boîte : une seule pile. */
.modal .grid--2, .modal .grid--3 { grid-template-columns: 1fr; }
/* Les actions de la modale restent visibles sans défiler jusqu'en bas. */
.modal .billing-form > .actions {
  position: sticky;
  inset-block-end: calc(-1 * var(--gap));
  padding: var(--gap-sm) 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--surface) 35%);
}
body.has-modal { overflow: hidden; }

@media (max-width: 640px) {
  /* Sous 640 px, la boîte prend tout l'écran : une fenêtre flottante y est illisible. */
  .modal { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .modal__panel { max-height: 100dvh; height: 100%; }
  .toasts { inset-inline: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .topload.is-running { animation: none; transform: scaleX(.6); }
  .btn.is-busy::after { animation-duration: 2s; }
  .toast { animation: none; }
}

/* ------------------------------------------------- liaison dans une fenêtre
   La plateforme interdit l'iframe (X-Frame-Options: DENY) : le consentement se fait
   forcément dans une fenêtre. Ce voile dit à l'écran resté derrière ce qui se passe,
   et rend la main si la fenêtre s'est perdue sous une autre. */
.linking {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: grid;
  place-items: center;
  padding: var(--gap);
  background: rgba(26, 20, 28, .45);
}
.linking__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-sm);
  width: min(400px, 100%);
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
  border-radius: var(--r-frame);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  text-align: center;
}
.linking__box > * { margin: 0; }
.linking__spin {
  width: 30px;
  height: 30px;
  border: 3px solid var(--accent-tint);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: kln-spin .8s linear infinite;
}
.linking__title { font-size: 16px; font-weight: 650; }
.linking__text { color: var(--ink-2); font-size: 14px; }
.linking .actions { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .linking__spin { animation-duration: 2.4s; }
}

/* ------------------------------------------------- lignes cliquables et actions rapides */
.row-link { cursor: pointer; }
.row-link:hover { background: var(--bg-2); }
.row-link:focus-within { background: var(--bg-2); }

.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.rowacts {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}
.rowacts > * { margin: 0; }
/* Les actions n'apparaissent qu'au survol sur grand écran : la liste reste calme, et
   l'action reste atteignable au clavier (focus) comme au doigt (toujours visible en tactile). */
@media (hover: hover) and (min-width: 769px) {
  .rowacts { opacity: 0; transition: opacity .12s ease; }
  tr:hover .rowacts, tr:focus-within .rowacts { opacity: 1; }
}
.iconbtn--sm { min-width: var(--tap); min-height: var(--tap); }

/* ------------------------------------------------- logo et couleur des documents */
/* Damier léger : un PNG à fond transparent se voit tel qu'il sera imprimé. */
.logobox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, var(--bg-2) 25%, transparent 25%, transparent 75%, var(--bg-2) 75%),
    linear-gradient(45deg, var(--bg-2) 25%, transparent 25%, transparent 75%, var(--bg-2) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px;
}

.colorpick { display: flex; align-items: center; gap: var(--gap-sm); }
.colorpick > * { margin: 0; }
.colorpick input[type="color"] {
  width: 64px;
  height: var(--tap);
  padding: 4px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  background: var(--surface);
  cursor: pointer;
}
.colorpick__hex {
  font: 13px/1 var(--font-mono);
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ==========================================================================
   Fiche d'un document : barre d'actions, puis la feuille telle qu'imprimée.
   ========================================================================== */
.doctools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap-sm) var(--gap);
}
.doctools > * { margin: 0; }
.doctools__id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.doctools__id > * { margin: 0; }
.doctools__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 22px;
}
.doctools__sub { color: var(--ink-2); font-size: 14px; }
.doctools .actions { flex: 0 0 auto; }

/* En lecture, la feuille n'a pas de champs : les blocs se lisent comme un document. */
.docedit--read .sheet__meta--read {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}
.docedit--read .sheet__meta--read > div {
  /* `flex: 1 1 130px` de .sheet__meta s'applique à la hauteur une fois la pile verticale :
     chaque ligne faisait 130 px de haut. En lecture, chaque ligne fait sa taille. */
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: var(--gap-sm);
}
.docedit--read .sheet__meta--read dt { color: var(--ink-3); }
.docedit--read .sheet__meta--read dd { margin: 0; font-weight: 600; }
.docedit--read .sheet__client-name { font-weight: 650; }
.docedit--read .sheet__parties { grid-template-columns: 1fr; }
.docedit--read .table--sheet { font-size: 13.5px; }
.docedit--read .table--sheet td, .docedit--read .table--sheet th { padding-inline: 0; }
.docedit--read .table--sheet th:first-child, .docedit--read .table--sheet td:first-child { padding-inline-start: var(--gap); }
.docedit--read .table--sheet th:last-child, .docedit--read .table--sheet td:last-child { padding-inline-end: var(--gap); }

/* Actions du panneau : une pile, chaque bouton pleine largeur, un seul écart. */
.actions--stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--gap-sm);
}
.actions--stack > * { margin: 0; }
.actions--stack form { display: contents; }
.docact__pct {
  display: flex !important;
  align-items: flex-end;
  gap: var(--gap-xs);
}
.docact > summary { width: 100%; }

/* Cibles tactiles des liens isolés de la fiche : la hauteur vient d'un rembourrage
   invisible, le texte ne bouge pas. (La règle WCAG dispense les liens au fil d'une
   phrase, pas ceux-ci, qui sont des commandes.) */
.crumb,
.doctools .crumb,
.docedit--read .sheet__party a,
.docedit--read .defs a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap);
}

/* ------------------------------------------------- identifiants du connecteur
   Une valeur qu'on recopie dans un autre logiciel : lisible, en chasse fixe, et
   copiable d'un bouton. Le conteneur porte le seul écart, les lignes n'ont pas de marge. */
.creds {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}
.creds > * { margin: 0; }
.creds__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--gap-sm);
}
.creds__row > * { margin: 0; }
.creds__label {
  flex: 0 0 auto;
  min-width: 128px;
  color: var(--ink-3);
  font-size: 13.5px;
}
.creds__value {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  min-width: 0;
}
.creds__value code {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  background: var(--bg-2);
  font-size: 13px;
  line-height: 1.35;
  /* Un secret est long et sans espace : il doit se couper, jamais déborder. */
  overflow-wrap: anywhere;
  word-break: break-all;
  user-select: all;
}
.creds__copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.creds__copy:hover { background: var(--bg-2); color: var(--ink); }
.creds__copy.is-copied { border-color: var(--ok); background: var(--ok-bg); color: var(--ok-fg); }

/* ------------------------------------------------- mise en route, une étape à la fois
   Les étapes franchies se replient, l'étape courante est la seule ouverte, les suivantes
   sont verrouillées. On voit où on en est sans dérouler quatre écrans. */
.setup--guide .setup__step.is-locked { opacity: .55; }
.setup--guide .setup__step.is-locked .setup__num { background: var(--bg-3); color: var(--ink-3); }
.setup--guide .setup__step.is-current {
  /* Un filet d'accent à gauche : l'œil tombe dessus sans avoir à lire les titres. */
  box-shadow: inset 3px 0 0 var(--accent-strong);
  background: var(--surface-2);
}
.setup--guide .setup__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap-sm);
}
.setup__locked {
  display: flex;
  align-items: center;
  gap: var(--gap-xs);
  color: var(--ink-3);
  font-size: 14px;
}
.setup__fold > summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.setup__fold > summary::marker, .setup__fold > summary::-webkit-details-marker { color: var(--ink-4); }
.setup__fold-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  padding-block-start: var(--gap-sm);
}
.setup__fold-body > * { margin: 0; }

/* Marqueur d'un champ exigé pour finaliser une facture. Un mot plutôt qu'un astérisque :
   personne n'a jamais cherché la légende d'un astérisque. */
.req {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: 1px;
}

/* ------------------------------------------------- opération longue en cours */
.syncing {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 14px 16px;
  border: 1px solid var(--edge-2);
  border-radius: var(--r-tile);
  background: var(--surface-2);
}
.syncing > * { margin: 0; }
.syncing .linking__spin { width: 22px; height: 22px; border-width: 2.5px; flex: 0 0 auto; }
.syncing__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.syncing__text > * { margin: 0; }
.syncing__text p { color: var(--ink-2); font-size: 14px; }
