:root {
  --steel-900: #0f2557;
  --steel-700: #173b8f;
  --steel-500: #2a5cc4;
  --steel-100: #e7eefb;
  --brand-red: #d0161c;
  --spark: #d9822b;
  --ink: #1b2430;
  --ink-soft: #5b6878;
  --line: #d6dee8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1f7a46;
  --ok-bg: #e4f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --ko: #a12020;
  --ko-bg: #fde8e8;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--steel-700);
  color: #fff;
  border-bottom: 3px solid var(--brand-red);
}
.topbar__logo { border-radius: 50%; background: #fff; object-fit: contain; padding: 1px; }
.topbar__titles { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 17px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 2px 0 0; font-size: 13px; opacity: .85; }

.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.15); }
.badge.is-online { background: #2e8b57; }
.badge.is-offline { background: var(--spark); }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--spark); color: #fff; font-weight: 600; }

.layout { flex: 1; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 0; }
.layout > * { min-width: 0; }
.modules { background: var(--card); border-right: 1px solid var(--line); padding: 16px 12px; }
.modules__title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 8px 8px; }
.modules ul { list-style: none; margin: 0; padding: 0; }
.modules li { font-size: 14px; }
.modules li.is-soon { padding: 9px 10px; color: var(--ink-soft); }
.modules a { display: block; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.modules a:hover { background: var(--bg); }
.modules a.is-active { background: var(--steel-100); color: var(--steel-700); font-weight: 600; }
.modules li.is-soon::after { content: "bientôt"; float: right; font-size: 11px; color: #9aa6b4; }

.content { padding: 24px; max-width: 1180px; outline: none; }
.content__head h2 { margin: 0 0 4px; font-size: 22px; }
.content__head p { margin: 0 0 20px; color: var(--ink-soft); }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.check { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.check h3 { margin: 0 0 6px; font-size: 15px; }
.check__value { margin: 0; font-size: 14px; color: var(--ink-soft); white-space: pre-line; }
.check.is-ok { border-left-color: var(--ok); }
.check.is-ok h3::before { content: "✔ "; color: var(--ok); }
.check.is-warn { border-left-color: var(--spark); background: var(--warn-bg); }
.check.is-warn h3::before { content: "! "; color: var(--warn); }
.check.is-ko { border-left-color: var(--ko); background: var(--ko-bg); }
.check.is-ko h3::before { content: "✘ "; color: var(--ko); }

.btn { font: inherit; font-size: 14px; font-weight: 600; padding: 9px 14px; border: 0; border-radius: 8px; background: var(--steel-700); color: #fff; cursor: pointer; margin-top: 10px; }
.btn:hover { background: var(--steel-500); }
.btn--light { background: #fff; color: var(--steel-900); margin: 0; }

.inline-form { margin-top: 10px; }
.inline-form label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.inline-form__row { display: flex; gap: 8px; align-items: center; }
.inline-form__row .btn { margin-top: 0; }
.inline-form input { font: inherit; width: 90px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; text-transform: uppercase; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--ko); min-height: 1em; }

.tests-link { margin-top: 24px; font-size: 14px; }
.tests-link a { color: var(--steel-500); }

.footer { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); text-align: center; font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); background: var(--card); }

@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .modules { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 8px; }
  .modules ul { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  .modules li { white-space: nowrap; flex: none; }
  .modules li.is-soon { display: none; }
  .modules li.is-soon::after { content: ""; }
  .modules__title { display: none; }
  .content { padding: 16px; }
}

/* ---------- Lot 2 : écrans de gestion ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head__actions .btn { margin-top: 0; }
.btn--ghost { background: transparent; color: var(--steel-700); border: 1px solid var(--line); }
.btn--ghost:hover { background: var(--steel-100); }
.btn:disabled { opacity: .6; cursor: wait; }

.notice { padding: 10px 14px; margin-bottom: 16px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-size: 14px; border: 1px solid #f1d9a6; }
.notice a { color: inherit; font-weight: 600; }
.notice a.btn { color: #fff; } /* bouton dans un avis : texte blanc lisible sur fond bleu */
.notice a.btn--ghost { color: var(--steel-700); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar select, .search { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.search { flex: 1 1 240px; min-width: 0; }
.check-inline { font-size: 14px; color: var(--ink-soft); display: inline-flex; gap: 6px; align-items: center; }
.segmented { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.segmented button { font: inherit; font-size: 14px; border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-soft); }
.segmented button.is-active { background: var(--steel-700); color: #fff; }

.count { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-soft); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); margin: 0; }
.muted { color: var(--ink-soft); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); background: #f8fafc; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover, .table tr.is-clickable:focus { background: var(--steel-100); outline: none; }
.is-inactive { opacity: .6; }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--steel-100); color: var(--steel-700); margin-left: 6px; }
.table td .tag:first-child, .tags-row .tag:first-child { margin-left: 0; }
.tag--supplier { background: #f6ebdf; color: #8a4b12; }
.tag--both { background: #e9e6f7; color: #4a3d8f; }
.tag--off { background: #eceff3; color: var(--ink-soft); }
.tags-row { margin: -6px 0 16px; }

.back { display: inline-block; margin-bottom: 10px; font-size: 14px; color: var(--steel-500); text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; font-size: 14px; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.tiles { display: grid; gap: 10px; align-content: start; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tile span { font-size: 13px; color: var(--ink-soft); }
.tile strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.tile--due { border-color: var(--spark); }
.tile--due strong { color: #9a4d0b; }

.history { margin-bottom: 18px; }
.history h3 { font-size: 15px; margin: 0 0 8px; }
.history .empty { padding: 12px; text-align: left; }
.history__row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-top: 0; font-size: 14px; }
.history__row:first-of-type { border-top: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
.history__row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.history__row:only-of-type { border-radius: var(--radius); }

.dialog { border: 0; border-radius: 12px; padding: 20px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 50px rgba(15, 42, 66, .3); }
.dialog::backdrop { background: rgba(15, 42, 66, .45); }
.dialog__title { margin: 0 0 14px; font-size: 18px; }
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form__field { display: flex; flex-direction: column; gap: 4px; }
.form__field--wide { grid-column: 1 / -1; }
.form__field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.form__field .req { color: var(--ko); }
.form__field input, .form__field select, .form__field textarea, .dialog input { font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; min-width: 0; }
.form__field textarea { resize: vertical; }
.form__field input:focus, .form__field select:focus, .form__field textarea:focus, .dialog input:focus, .search:focus { outline: 2px solid var(--steel-500); outline-offset: 1px; }
.form__hint { color: var(--ink-soft); font-size: 12px; }
.form-error { color: var(--ko); font-size: 14px; min-height: 1.2em; margin: 10px 0 0; white-space: pre-line; }
.form__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.form__actions .btn { margin-top: 0; }
.spacer { flex: 1; }

.mini-list { margin-top: 12px; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.mini-list .empty { border: 0; }
.mini-list__row { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-bottom: 1px solid #edf1f5; font-size: 14px; }
.mini-list__row:last-child { border-bottom: 0; }
.mini-list__row > span { flex: 1; min-width: 0; }
.link { font: inherit; font-size: 13px; background: none; border: 0; color: var(--steel-500); cursor: pointer; padding: 4px; }
.link:hover { text-decoration: underline; }
.dialog .inline-form__row input { flex: 1; width: auto; }
.dialog .inline-form__row .input-short { flex: 0 0 140px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; color: #fff; background: var(--ok); box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: opacity .2s, transform .2s; z-index: 10; max-width: calc(100vw - 32px); }
.toast--ko { background: var(--ko); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .form__grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table { border: 0; background: transparent; }
  .table tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 6px 0; }
  .table td { border: 0; padding: 4px 14px; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--ink-soft); font-size: 13px; text-align: left; flex: none; }
  .table td.num { text-align: right; }
  .history__row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dialog { padding: 16px; }
  .dialog .inline-form__row { flex-wrap: wrap; }
  .dialog .inline-form__row .input-short { flex: 1 1 100%; }
}

/* ---------- Lot 3 : documents, paramètres ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: 13px; }
.btn--small { font-size: 13px; padding: 6px 10px; margin-top: 8px; }
a.btn { display: inline-block; text-decoration: none; }
.page-head__actions a.btn { margin-top: 0; }
.links-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; margin: -6px 0 14px; }
.links-row a { color: var(--steel-500); }
.words-line { margin: -6px 0 14px; }

.tag--status { margin-left: 0; }
.tag--draft { background: #eceff3; color: #4a5568; }
.tag--sent, .tag--issued { background: #e3edfc; color: #1d4ea8; }
.tag--accepted, .tag--validated, .tag--converted { background: var(--ok-bg); color: var(--ok); }
.tag--refused, .tag--cancelled { background: var(--ko-bg); color: var(--ko); }
.tag--expired { background: var(--warn-bg); color: var(--warn); }

.section-title { font-size: 16px; margin: 20px 0 8px; }
.form__grid--3 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); }
.doc-form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.doc-form .form__field select, .doc-form .form__field input, .doc-form textarea, .doc-line select, .doc-line input {
  font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; min-width: 0;
}
.doc-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; margin-bottom: 12px; background: #fbfcfe; }
.doc-group__head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 8px; }
.doc-line { display: grid; grid-template-columns: 22px minmax(0, 3.2fr) 72px 110px 104px 72px 110px 118px 26px; gap: 8px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.doc-line__num { font-size: 12px; color: var(--ink-soft); padding-top: 10px; text-align: right; }
.doc-line__main { display: grid; gap: 6px; }
.doc-line__picker { font-size: 13px !important; background: var(--steel-100) !important; border-style: dashed !important; }
.doc-line__desc { resize: vertical; }
.doc-line__cell { min-width: 0; display: grid; gap: 4px; font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
.doc-line__cell--amount { text-align: right; }
.doc-line__amount { font-size: 14px; color: var(--ink); font-weight: 600; text-transform: none; letter-spacing: 0; padding-top: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-line__remove { font-size: 16px; color: var(--ko); padding-top: 24px; }
.doc-bottom { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; margin-top: 14px; align-items: start; }
.doc-totals { background: var(--steel-100); border-radius: var(--radius); padding: 14px 16px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0 0 8px; font-size: 15px; }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .grand { font-size: 18px; color: var(--steel-900); font-weight: 700; border-top: 1px solid #c8d6f0; padding-top: 6px; }

.tile--main { border-color: var(--steel-500); }
.tile--main strong { color: var(--steel-700); }
.tiles--row { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.table--doc { margin-bottom: 20px; }
.table--doc .row-subtotal td { font-weight: 700; background: #f3f6fb; }
.table--doc .row-group td { font-weight: 700; font-style: italic; }
.payments .btn { margin: 0 0 12px; }
.history__list .history__row:first-child { border-top: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }

.dialog--wide { width: min(860px, calc(100vw - 24px)); }
.import-sources { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.import-sources .btn { margin-top: 0; }
.import-summary { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.import-summary .tag { margin-left: 0; }
.tag--imp-created { background: var(--ok-bg); color: var(--ok); }
.tag--imp-updated { background: #e3edfc; color: #1d4ea8; }
.tag--imp-error { background: var(--ko-bg); color: var(--ko); }
.import-row--error { background: #fff6f6; }

.settings-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.settings-block .facts { border: 0; padding: 0; }
.settings-block__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.settings-block__head h3 { margin: 0; font-size: 16px; }
.settings-block__head .btn { margin-top: 0; }
.settings-logo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.settings-logo { width: 140px; height: 140px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 6px; }
.settings-logo-actions { display: grid; gap: 8px; justify-items: start; }
.settings-logo-actions .btn { margin-top: 0; }

@media (max-width: 1100px) {
  .doc-line { position: relative; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .doc-line__num { display: none; }
  .doc-line__main { grid-column: 1 / -1; padding-right: 30px; }
  .doc-line__remove { position: absolute; top: 8px; right: 0; padding-top: 6px; }
}
@media (max-width: 760px) {
  .form__grid--3 { grid-template-columns: minmax(0, 1fr); }
  .doc-form { padding: 12px; }
  .doc-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-group__head { grid-template-columns: minmax(0, 1fr); }
  .doc-bottom { grid-template-columns: minmax(0, 1fr); }
  .tiles--row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Catalogue : prix à définir ---------- */
.tag--todo { background: var(--warn-bg); color: var(--warn); margin-left: 0; }
.notice--info { background: #eef4ff; color: var(--steel-900); border-color: #c9d9f7; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice--info .btn { margin-top: 0; }
.doc-lines-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin: 20px 0 8px; }
.doc-lines-head .section-title { margin: 0; }
.doc-lines-head .btn { margin-top: 0; }
.in-price:placeholder-shown { border-color: var(--spark) !important; background: var(--warn-bg) !important; }

/* ---------- Fenêtre « Ajouter depuis le catalogue » ---------- */
.doc-group__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.picker-list { max-height: 58vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px 8px; }
.picker-group { margin: 12px 4px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.picker-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; width: 100%; text-align: left; font: inherit; font-size: 14px; padding: 9px 10px; margin: 2px 0; border: 1px solid transparent; border-radius: 8px; background: #fff; cursor: pointer; }
.picker-item:hover, .picker-item:focus { background: var(--steel-100); border-color: #c9d9f7; outline: none; }
.picker-item.is-added { background: var(--ok-bg); border-color: #b9e2c7; }
.picker-item.is-added .picker-item__name::before { content: "✔ "; color: var(--ok); }
.picker-item__name { font-weight: 600; }
.picker-item__code { font-size: 12px; color: var(--ink-soft); }
.picker-item__price { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 760px) {
  .picker-item { grid-template-columns: minmax(0, 1fr) auto; }
  .picker-item__code { grid-column: 1; grid-row: 2; }
}

/* ---------- Chantiers et dépenses (0.4.0) ---------- */
.tiles--row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.block { display: block; }
.progress { position: relative; height: 18px; min-width: 110px; background: #e9eef5; border-radius: 9px; overflow: hidden; }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--steel-500), var(--steel-700)); border-radius: 9px; }
.progress__text { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink); text-shadow: 0 0 3px #fff; }
.site-progress { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; margin: 0 0 14px; max-width: 520px; }
.budget-line { margin: -4px 0 18px; }
.section-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin: 0 0 8px; }
.section-head h3 { margin: 0; }
.section-head__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.history__row > .link { justify-self: end; }
.history__row.history__row--actions { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip { display: inline-flex; gap: 8px; align-items: baseline; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font: inherit; font-size: 13px; color: var(--ink); }
button.chip { cursor: pointer; }
button.chip:hover, .chip.is-active { border-color: var(--steel-500); background: var(--steel-100); }
.chip strong { font-variant-numeric: tabular-nums; }
.date-range { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.table tr.is-cancelled td { color: var(--ink-soft); }
.table tr.is-cancelled td.num { text-decoration: line-through; }
.attachment-preview { display: block; max-width: min(100%, 520px); max-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: #fff; }
.notes { display: grid; gap: 8px; }
.note { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--steel-500); border-radius: var(--radius); padding: 10px 14px; }
.note__head { display: flex; gap: 10px; align-items: center; margin: 0 0 4px; font-size: 14px; }
.note__text { margin: 0; white-space: pre-line; font-size: 14px; }
.tag--site-planned { background: #eceff3; color: #4a5568; }
.tag--site-in_progress { background: #e3edfc; color: #1d4ea8; }
.tag--site-suspended { background: var(--warn-bg); color: var(--warn); }
.tag--site-completed { background: var(--ok-bg); color: var(--ok); }
.tag--site-cancelled { background: var(--ko-bg); color: var(--ko); }
@media (max-width: 760px) {
  .history__row.history__row--actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .site-progress { max-width: none; }
  .progress { min-width: 0; }
}
.toolbar select, .toolbar input { max-width: 100%; min-width: 0; }
@media (max-width: 760px) {
  .toolbar > select, .toolbar > .search { flex: 1 1 100%; width: 100%; }
}

/* ---------- Tableau de bord et rapports (0.5.0) ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin: 0 0 16px; }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; min-width: 0; }
a.kpi:hover, a.kpi:focus { border-color: var(--steel-500); box-shadow: 0 2px 10px rgba(23, 59, 143, .08); }
.kpi__label { font-size: 13px; color: var(--ink-soft); }
.kpi__value { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--ink); overflow-wrap: anywhere; }
.kpi--main { border-color: var(--steel-500); }
.kpi--main .kpi__value { color: var(--steel-700); }
.kpi--due { border-color: #e7b46a; background: #fffaf0; }
.kpi__change { font-size: 12px; }
.is-good { color: var(--ok); }
.is-bad { color: var(--ko); }
.chart-card { margin: 0 0 18px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.chart-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i, .chart-tooltip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.chart-wrap { position: relative; }
.chart { display: block; max-width: 100%; overflow: visible; }
.chart-grid { stroke: #e8edf3; stroke-width: 1; }
.chart-baseline { stroke: #b8c3d1; stroke-width: 1; }
.chart-axis { font-size: 11px; fill: var(--ink-soft); font-family: inherit; }
.chart-hit { fill: transparent; cursor: default; outline: none; }
.chart-hit:hover, .chart-hit:focus { fill: rgba(42, 92, 196, .06); }
.chart-tooltip { position: absolute; top: 4px; transform: translateX(-50%); display: grid; gap: 2px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); font-size: 12px; pointer-events: none; white-space: nowrap; z-index: 2; }
.chart-tooltip__row { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.chart-tooltip__row b { margin-left: auto; padding-left: 10px; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--steel-700); }
.table--compact td, .table--compact th { padding: 6px 10px; }
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.panel__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.panel__head h3 { margin: 0; font-size: 15px; }
.panel__head a { font-size: 13px; }
.panel__list { display: grid; }
.panel__row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid #edf1f5; color: var(--ink); text-decoration: none; font-size: 14px; min-width: 0; }
.panel__row:first-child { border-top: 0; }
.panel__row:hover strong { color: var(--steel-700); }
.panel__row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.panel__value { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.panel__value--progress { width: 120px; }
.panel .empty { padding: 10px 0; text-align: left; }
.segmented--wrap { flex-wrap: wrap; }
.report-block { margin: 0 0 18px; }
.report-period { margin: 0 0 10px; }
.table--report tfoot td { font-weight: 700; background: #f3f6fb; border-top: 2px solid var(--line); }
.print-only { display: none; }
@media (max-width: 900px) {
  .panels { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpi__value { font-size: 17px; }
  .segmented--wrap { display: flex; }
  .segmented--wrap button { flex: 1 1 30%; }
  .table--report tfoot td:empty { display: none; }
}
/* Petits téléphones : montants de plusieurs dizaines de millions lisibles sans déborder. */
@media (max-width: 420px) { .kpi__value { font-size: 15px; } .kpi { padding: 12px; } }
@media (max-width: 359px) { .kpis { grid-template-columns: minmax(0, 1fr); } }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .topbar, .modules, .footer, .banner, .no-print, .page-head__actions, .toast, .back, .chart-table summary { display: none !important; }
  .layout, .content { display: block; padding: 0; margin: 0; }
  .print-only { display: block; }
  .print-title { font-weight: 700; font-size: 14px; margin: 0 0 10px; }
  .tile, .kpi, .table, .chart-card, .panel { break-inside: avoid; box-shadow: none; }
  .table tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
@media (max-width: 760px) {
  .tile { flex-wrap: wrap; min-width: 0; }
  .tile strong { font-size: 16px; }
}

/* ---------- Sauvegarde (0.6.0) ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 0 0 16px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card h4 { margin: 16px 0 8px; font-size: 14px; }
.card > p { font-size: 14px; line-height: 1.5; }
.notice--ok { background: var(--ok-bg); color: var(--ok); border-color: #b9e2c7; }
.notice--danger { background: #fdecec; color: #7a1414; border-color: #f2b8b8; }
.btn--danger { background: var(--ko); border-color: var(--ko); }
.btn--danger:hover { background: #861a1a; }
.file-pick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; margin: 8px 0; }
.file-pick input { max-width: 100%; font: inherit; font-weight: 400; }
.backup-summary { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; margin: 12px 0; }
.notice input { font: inherit; padding: 4px 8px; border: 1px solid #e2c27f; border-radius: 6px; margin-left: 4px; width: 140px; }
@media (max-width: 760px) {
  .backup-summary { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Saisie directe d'un nouveau client / fournisseur (0.6.1) ---------- */
.new-party { display: block; margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: #eef4ff; border: 1px solid #c9d9f7; color: var(--steel-900); font-size: 13px; font-weight: 400; }
.new-party__note { display: block; font-weight: 600; margin-bottom: 6px; }
.new-party__fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 6px; }
.new-party__fields input { font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 0; }
@media (max-width: 760px) { .new-party__fields { grid-template-columns: minmax(0, 1fr); } }

/* Tableaux larges (catalogue, rapports) sur tablette : défilement dans le cadre, jamais la page entière. */
.list-zone, .report-block { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 1100px) { .table th, .table td { padding: 8px 9px; } }
.table tr.row-more td { text-align: center; background: #f8fafc; }
.table tr.row-more td::before { display: none; }
@media print { .row-more { display: none !important; } }

/* Téléphone et tablette : cibles tactiles d'au moins 40 px (doigt), sans changer la mise en page sur PC. */
@media (pointer: coarse), (max-width: 760px) {
  .btn, .btn--small, .segmented button { min-height: 40px; }
  .modules a { min-height: 40px; display: flex; align-items: center; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select { min-height: 40px; }
  a.btn { display: inline-flex; align-items: center; }
  .check-inline { min-height: 40px; }
  .check-inline input[type=checkbox], .check-inline input[type=radio] { width: 20px; height: 20px; }
  .back, .panel__head a, .tests-link a { display: inline-flex; align-items: center; min-height: 40px; }
  .back { margin-bottom: 2px; }
  .link, .doc-line__remove { min-width: 40px; min-height: 40px; }
  summary { padding: 12px 0; }
  input[type=file] { min-height: 40px; }
}

/* Quatorzième audit : un texte sans espace (nom collé, référence de virement,
   motif) se coupe au lieu d'élargir la page sur téléphone. « anywhere » seulement
   pour les paragraphes ; dans les tableaux et les tuiles, « break-word » ne coupe
   qu'en dernier recours (dates, montants et titres de colonnes restent entiers). */
.content p, .content li, .content dd, .content .form__hint, .content .tags-row, .content .new-party { overflow-wrap: anywhere; }
.content td, .content th, .content h2, .content h3, .content .history__row > * { overflow-wrap: break-word; }
.content .history__row > * { min-width: 0; }
.content .page-head h2 { overflow-wrap: anywhere; min-width: 0; }
/* Tuiles : le montant passe sous le libellé quand la place manque (jamais coupé). */
.tile { flex-wrap: wrap; }
.tile strong { white-space: nowrap; }

/* Écrans moyens (tablette, petit portable) : un tableau trop large défile
   horizontalement au lieu d'avoir ses dernières colonnes coupées (montants). */
.table-scroll { max-width: 100%; overflow-x: auto; border-radius: var(--radius); }
.table-scroll + .row-more, .table-scroll > .table { margin-bottom: 0; }
@media print { .table-scroll { overflow: visible; } }
.old-version { margin: 10px 16px 0; }

/* Signature du développeur, visible en permanence (barre du haut et menu). */
.topbar__credit { white-space: nowrap; }
.topbar__credit strong { font-weight: 700; letter-spacing: .02em; }
.modules__credit { margin: 18px 12px 6px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.45; color: var(--ink-soft); }
.modules__credit strong { color: var(--steel-700, #173b8f); font-size: 13px; letter-spacing: .03em; }
@media (max-width: 760px) {
  .topbar__credit { display: block; font-size: 11px; }
  .topbar__dot { display: none; }
  .modules__credit { display: none; } /* sur téléphone, le menu est une barre horizontale : la signature reste dans la barre du haut */
}

/* ---- Comptes : personne connectée, écran de connexion ---- */
.user-chip { border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; cursor: pointer; max-width: 42vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip:hover { background: rgba(255,255,255,.22); }
body.is-locked .modules, body.is-locked .user-chip { display: none !important; }
body.is-locked .layout { grid-template-columns: minmax(0, 1fr); }
.login { max-width: 460px; margin: 24px auto; }
.login__people { display: grid; gap: 8px; margin: 12px 0 16px; }
.login__person { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font: inherit; cursor: pointer; }
.login__person:hover, .login__person.is-active { border-color: var(--steel-700); background: var(--steel-100); }
.login__person small { color: var(--ink-soft); }
.login__pin { font-size: 22px; letter-spacing: .3em; text-align: center; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.recovery-code { font: 700 24px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .08em; text-align: center; padding: 14px; border: 2px dashed var(--brand-red); border-radius: 10px; background: #fff; margin: 12px 0; overflow-wrap: anywhere; }
.journal-table td small { display: block; color: var(--ink-soft); }
