:root {
  --accent: #B3121B;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, white);
  --accent-faint: color-mix(in srgb, var(--accent) 5%, white);
  --ink: #17201f;
  --ink-2: #4f5a59;
  --ink-3: #8a9493;
  --line: #d9e2e0;
  --bg: #edf2f1;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #9a5b00;
  --warn-soft: #fdf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe4e2;
  --done: #3c4f8f;
  --done-soft: #e6eaf8;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(30, 20, 10, .05), 0 4px 16px rgba(30, 20, 10, .04);
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-family: var(--display); font-style: italic; font-size: 2rem; font-weight: 700; letter-spacing: -.005em; }
.display { font-family: var(--display); font-style: italic; font-weight: 700; }
.eyebrow { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }

/* ---------- Mise en page ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--card); border-right: 1px solid var(--line);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .dot { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); flex: none;
  display: grid; place-items: center; color: white; font-weight: 700; }
.brand b { font-size: .98rem; line-height: 1.15; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .count { background: var(--accent); color: white; border-radius: 99px; font-size: .72rem; padding: 1px 7px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 8px 0; font-size: .88rem; }
.side-foot .role { color: var(--ink-3); font-size: .8rem; }
.side-foot button { margin-top: 8px; }

main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; }
.topbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card, .stack > * + * { margin-top: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { margin-top: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--accent); }
.tile .label { font-size: .8rem; color: var(--ink-3); font-weight: 500; }
.tile .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: .8rem; color: var(--ink-2); margin-top: 2px; }
.tile.accent { background: var(--accent); color: white; border-color: var(--accent); }
.tile.accent .label, .tile.accent .hint { color: rgba(255,255,255,.85); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #faf8f5; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }
th.right, td.right { text-align: right; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 10px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.muted { background: #efebe6; color: var(--ink-2); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.done { background: var(--done-soft); color: var(--done); }
.badge.role-admin { background: var(--accent-soft); color: var(--accent); }

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--done-soft); color: var(--done); }

/* ---------- Formulaires ---------- */
form.inline { display: grid; gap: 10px; align-items: end; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fields .wide { grid-column: span 2; }
.fields .full { grid-column: 1 / -1; }
label { display: grid; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--ink); background: white; border: 1px solid #d8d2cb; border-radius: 8px;
  padding: 9px 11px; width: 100%; min-width: 0;
}
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.help { font-weight: 400; color: var(--ink-3); font-size: .78rem; }

button, .btn {
  font: inherit; font-weight: 600; font-size: .9rem; border-radius: 8px; padding: 9px 15px; cursor: pointer;
  border: 1px solid #d8d2cb; background: white; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--ink-3); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { filter: brightness(1.08); }
button.ok { background: var(--ok); border-color: var(--ok); color: white; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.ghost { border-color: transparent; background: transparent; padding: 6px 8px; color: var(--ink-3); }
button.ghost:hover { color: var(--bad); background: var(--bad-soft); }
button.link { border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; }
button:disabled { opacity: .55; cursor: wait; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border-radius: 99px; padding: 5px 12px; font-size: .84rem; font-weight: 600; }
.chip.on { background: var(--ink); color: white; border-color: var(--ink); }

/* ---------- Fenêtres ---------- */
dialog { border: none; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(30, 20, 10, .35); }
dialog .dlg-body { padding: 22px; display: grid; gap: 16px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; background: var(--bg); border-radius: 8px; padding: 12px; text-align: center; letter-spacing: .08em; user-select: all; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; }
.toast { background: var(--ink); color: white; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); font-weight: 500; animation: pop .2s ease-out; }
.toast.error { background: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Écrans de connexion ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(420px, 100%); padding: 30px; }
.auth h1 { margin: 14px 0 6px; }
.auth form { display: grid; gap: 14px; margin-top: 20px; }

/* ---------- Documents (aperçu + impression) ---------- */
.doc-preview { background: #e9e5e0; border-radius: var(--radius); padding: 24px; overflow-x: auto; }
.doc {
  background: white; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 16mm 15mm;
  font-size: 10pt; color: #111; box-shadow: 0 2px 14px rgba(0,0,0,.12); position: relative; line-height: 1.4;
}
.doc .d-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--accent); padding-bottom: 12px; }
.doc .d-org b { font-size: 13pt; display: block; margin-bottom: 2px; }
.doc .d-title { text-align: right; }
.doc .d-title h1 { font-size: 20pt; color: var(--accent); letter-spacing: .02em; }
.doc .d-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 18px 0; }
.doc .d-box { border: 1px solid #ddd; border-radius: 6px; padding: 10px 12px; }
.doc .d-box .k { font-size: 8pt; text-transform: uppercase; letter-spacing: .06em; color: #777; margin-bottom: 4px; }
.doc table { font-size: 9.5pt; margin-top: 8px; }
.doc th { font-size: 7.5pt; color: #555; background: #f4f2ef; border-bottom: 1px solid #ccc; padding: 6px 8px; }
.doc td { padding: 6px 8px; border-bottom: 1px solid #eee; }
.doc .d-total { margin-left: auto; width: 60%; margin-top: 12px; }
.doc .d-total td { border: none; padding: 4px 8px; }
.doc .d-total tr.grand td { font-size: 12pt; font-weight: 700; border-top: 2px solid #111; padding-top: 8px; }
.doc .d-section { margin-top: 18px; }
.doc .d-section h3 { font-size: 10pt; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); border-bottom: 1px solid #ddd; padding-bottom: 4px; }
.doc .d-foot { margin-top: 22px; font-size: 8.5pt; color: #444; display: grid; gap: 6px; }
.doc .d-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 26px; }
.doc .d-sign div { border: 1px solid #ccc; border-radius: 6px; height: 80px; padding: 8px; font-size: 8.5pt; color: #555; }
.doc .watermark { position: absolute; top: 40%; left: 0; right: 0; text-align: center; font-size: 72pt; font-weight: 800;
  color: rgba(0,0,0,.06); transform: rotate(-24deg); pointer-events: none; }
.doc .d-legal { font-size: 7.5pt; color: #777; text-align: center; position: absolute; bottom: 10mm; left: 15mm; right: 15mm; }

#print { display: none; }

/* ---------- Composants inspirés de l'outil existant ---------- */
.list-cards { display: grid; gap: 12px; }
.ncard { display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.ncard:hover { border-color: var(--accent); }
.ncard .ic { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.ncard .t { font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.ncard .s { color: var(--ink-3); font-size: .88rem; }
.ncard .amt { font-family: var(--display); font-style: italic; font-weight: 700; font-size: 1.5rem; white-space: nowrap; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: .82rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.pill.muted { background: #e6eeed; color: var(--ink-2); border-color: #cfdcda; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: #f3d9a8; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cf; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: #f2c3bf; }
.pill.done { background: var(--done-soft); color: var(--done); border-color: #ccd5f1; }
.pill.admin { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cf; }
.chip-info { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; background: var(--accent-faint); font-weight: 500; }
.big-total { font-family: var(--display); font-style: italic; font-weight: 700; font-size: 2.6rem; color: var(--accent); line-height: 1; }
.total-row { display: flex; align-items: baseline; gap: 18px; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.add-buttons { display: grid; gap: 10px; justify-items: center; margin: 18px 0; }
.dashed-btn { border: 1.5px dashed #b9c7c5; background: var(--card); border-radius: 14px; padding: 14px 24px; font-size: 1.02rem; min-width: 260px; justify-content: center; }
.dashed-btn:hover { border-color: var(--accent); color: var(--accent); }
.upload-tile { border: 1.5px dashed #b9c7c5; background: #e6eeed; border-radius: 14px; padding: 16px 18px; display: flex; align-items: center; gap: 12px; font-weight: 700; cursor: pointer; width: 100%; justify-content: flex-start; font-size: .98rem; }
.upload-tile:hover { border-color: var(--accent); }
.upload-tile .sub { font-weight: 400; color: var(--ink-3); font-size: .84rem; }
.upload-tile svg { color: var(--accent); flex: none; }
.doc-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; }
.doc-row .grow { flex: 1; min-width: 0; }
.doc-row .grow b { display: block; }
.tabs { display: flex; gap: 6px 22px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 18px 0; }
.tabs a { display: inline-flex; gap: 8px; align-items: center; padding: 10px 2px; color: var(--ink-2); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.sig-pad { border: 1.5px dashed #b9c7c5; background: #f6f9f9; border-radius: 14px; width: 100%; height: 190px; touch-action: none; display: block; cursor: crosshair; }
.sig-img { max-height: 120px; max-width: 100%; display: block; }
.hint { display: flex; gap: 8px; color: var(--ink-3); font-size: .9rem; margin-top: 8px; }
button.block { width: 100%; justify-content: center; padding: 14px; font-size: 1.02rem; border-radius: 14px; }
.lines .line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lines .line:last-child { border-bottom: none; }
.lines .line .m { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines .line .d { color: var(--ink-3); font-size: .85rem; }
.recap-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.recap-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 3px solid var(--ink); margin-top: 12px; padding-top: 14px; font-weight: 700; }
.recap-total .big-total { font-size: 2.2rem; }
dialog.sheet .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
dialog.sheet .dlg-head h2 { font-family: var(--display); font-style: italic; font-size: 1.7rem; }
.warn-box { display: flex; gap: 14px; align-items: center; background: var(--warn-soft); border: 1px solid #f3d9a8; border-radius: 14px; padding: 14px 16px; color: var(--warn); }
.warn-box .ico { background: white; border-radius: 12px; width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.form-stack { display: grid; gap: 14px; }
@media (max-width: 860px) {
  dialog.sheet { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .ncard { grid-template-columns: auto 1fr auto; }
  .ncard .pill { grid-column: 2; justify-self: start; }
  .ncard .amt { grid-row: 1 / span 2; grid-column: 3; }
  .ncard .ic { grid-row: 1 / span 2; }
  .dashed-btn { min-width: 0; width: 100%; }
  .big-total { font-size: 2.2rem; }
  h1 { font-size: 1.7rem; }
}
@page { size: A4; margin: 0; }
@media print {
  body { background: white; }
  #app, #toast, dialog { display: none !important; }
  #print { display: block; }
  #print .doc { box-shadow: none; margin: 0; width: auto; min-height: 297mm; }
  #print .watermark { color: rgba(0,0,0,.08); }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); height: 100%; }
  .shell.menu-open .side { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .topbar b { font-size: 1rem; }
  main { padding: 18px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head > h1:not(.keep), .page-head > div > h1:not(.keep) { display: none; }
  .page-head .sub { margin-top: 0; }
  .fields .wide { grid-column: 1 / -1; }
  h1 { font-size: 1.3rem; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .doc-preview { padding: 10px; }
  .doc { transform-origin: top left; }
}

/* ---------- Me Gusta : avatars, logo, calendrier, facture ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.brand img.logo { width: 44px; height: 44px; object-fit: contain; flex: none; }
.auth .brand img.logo { width: 84px; height: 84px; }
.side-foot .me { display: flex; align-items: center; gap: 10px; }
.big-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.big-action { display: flex; align-items: center; gap: 14px; padding: 20px 22px; border-radius: var(--radius); background: var(--card); border: 1.5px solid var(--line);
  font: inherit; font-size: 1.08rem; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left; box-shadow: var(--shadow); }
.big-action:hover { border-color: var(--accent); }
.big-action .ic { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; }
.big-action small { display: block; font-weight: 400; color: var(--ink-3); font-size: .86rem; margin-top: 2px; }
.line-card { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.line-card:last-child { border-bottom: none; }
.line-card:hover .lc-title { color: var(--accent); }
.line-card .lc-title { font-weight: 700; white-space: pre-line; }
.line-card .lc-meta { color: var(--ink-3); font-size: .86rem; }
.line-card .lc-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.lines .line.clickable { cursor: pointer; }
.lines .line.clickable:hover b { color: var(--accent); }
.segmented { display: inline-flex; border: 1px solid #d8d2cb; border-radius: 10px; padding: 3px; gap: 3px; background: var(--bg); }
.segmented button { border: none; background: transparent; padding: 7px 14px; }
.segmented button.on { background: var(--card); box-shadow: var(--shadow); color: var(--accent); }
.cal { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; text-transform: capitalize; }
.cal-head button.ghost { color: var(--ink); }
.cal-head button.ghost:hover { background: var(--bg); color: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .74rem; font-weight: 700; color: var(--ink-3); padding: 2px 0; }
.cal-day { padding: 0; height: 38px; justify-content: center; border-radius: 9px; font-variant-numeric: tabular-nums; font-weight: 500; }
.cal-day.today { border-color: var(--ink-3); }
.cal-day.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.cal-repeat summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .88rem; }
.cal-sel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .86rem; }
.cal-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 2px 4px 2px 10px; font-weight: 600; }
.cal-chip button { border: none; background: none; padding: 0 6px; color: inherit; font-size: 1rem; line-height: 1; }
.live-total { display: flex; justify-content: space-between; align-items: baseline; background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.live-total b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.perm { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.perm .help { margin-left: 26px; margin-top: -6px; }
.photo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-prev { max-height: 90px; max-width: 200px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }

.doc .d-logo { height: 54px; display: block; margin-bottom: 6px; }
.doc-inv { font-size: 9.5pt; }
.doc-inv .d-top { font-size: 8.5pt; color: #333; margin-bottom: 8px; }
.doc-inv .d-head { align-items: center; border-bottom: 3px solid var(--accent); }
.doc-inv .d-brand { display: flex; align-items: center; gap: 16px; }
.doc-inv .d-brand img { height: 96px; width: auto; }
.doc-inv .d-brand b { font-size: 17pt; letter-spacing: .02em; }
.doc-inv .d-num { display: flex; align-items: stretch; border: 1.5px solid #111; font-size: 11pt; }
.doc-inv .d-num span { background: #f0eeeb; padding: 6px 12px; font-weight: 700; }
.doc-inv .d-num b { padding: 6px 16px; min-width: 60px; text-align: center; color: var(--accent); }
.doc-inv .d-parties { grid-template-columns: 1.25fr 1fr; align-items: start; }
.doc .d-info { margin: 0; font-size: 9pt; }
.doc .d-info th { background: none; text-transform: none; letter-spacing: 0; font-size: 9pt; color: #555; font-weight: 600; text-align: right; padding: 3px 10px 3px 0; border: none; width: 48%; }
.doc .d-info td { padding: 3px 0; border: none; border-bottom: 1px solid #eee; font-weight: 600; }
.doc .d-objet { margin: -4px 0 10px; font-weight: 700; }
.doc .d-objet span { color: #666; font-weight: 400; }
.doc .d-lines th { background: #1b1b1b; color: #fff; }
.doc .d-lines td { border-bottom: 1px solid #ddd; }
.doc .d-desc { font-weight: 700; }
.doc .d-sub { color: #666; font-size: 8.5pt; margin-top: 2px; }
.doc .d-dates { columns: 4; column-gap: 18px; margin: 0; padding-left: 20px; font-size: 8.5pt; color: #333; }
.doc .d-lines tr:has(+ .d-dates-row) td { border-bottom: none; padding-bottom: 2px; }
.doc .d-dates-row td { padding-top: 0; }
.doc .d-dates li { break-inside: avoid; }
.doc-inv .d-total { width: 45%; }
.doc .d-rib { margin-top: 16px; border: 1px solid #ccc; border-radius: 6px; padding: 10px 12px; width: 70%; font-size: 8.5pt; break-inside: avoid; }
.doc .d-rib-t { font-weight: 700; font-size: 9pt; margin-bottom: 6px; color: var(--accent); }
.doc .d-rib-g { display: grid; gap: 4px; }
.doc .d-rib-g > div { display: flex; gap: 10px; }
.doc .d-rib-g span { color: #666; min-width: 92px; }
.doc .d-rib-codes { display: grid !important; grid-template-columns: repeat(4, auto); gap: 4px 14px !important; border-top: 1px solid #eee; border-bottom: 1px solid #eee; padding: 4px 0; }
.doc .d-rib-codes > div { display: grid; }
.doc .d-rib-codes span { min-width: 0; font-size: 7.5pt; }
.doc .mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: .03em; }
.doc-inv .d-legal { line-height: 1.5; }

.send-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
a.pill { text-decoration: none; }
ol.guide { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); }
ol.guide code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.addr { position: relative; }
.addr-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(20, 20, 20, .14); padding: 4px; display: grid; max-height: 260px; overflow: auto; }
.addr-list button { border: none; background: none; display: flex; gap: 8px; align-items: flex-start; text-align: left; padding: 8px 10px; border-radius: 8px; font-weight: 500; white-space: normal; }
.addr-list button:hover, .addr-list button.on { background: var(--bg); }
.addr-list button svg { color: var(--ink-3); margin-top: 3px; flex: none; }
.addr-list button.saved svg { color: var(--accent); }
.addr-list small { display: block; color: var(--ink-3); font-weight: 400; }
.route-box { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: end; }
.route-box .swap { grid-column: 2; grid-row: 1 / span 2; align-self: center; padding: 8px; border-radius: 50%; }
.place-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.place-chips button { padding: 4px 10px; border-radius: 99px; font-size: .82rem; font-weight: 600; }
.km-status { font-size: .86rem; color: var(--ink-3); display: flex; gap: 6px; align-items: center; min-height: 1.2em; }
.km-status.ok { color: var(--ok); }
.km-status.bad { color: var(--warn); }
.save-place { font-size: .82rem; }
.save-place-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.save-place-form input { width: auto; flex: 1 1 140px; padding: 6px 9px; }
.save-place-form button { padding: 6px 10px; }

.ik-preview > span { display: grid; gap: 2px; }
.ik-preview small { font-size: .78rem; }
.ik-preview b { color: var(--accent); }

.tiles.balance { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile.pos { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 7%, var(--card)); }
.tile.pos .value { color: var(--ok); }
.tile.neg { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: color-mix(in srgb, var(--bad) 7%, var(--card)); }
.tile.neg .value { color: var(--bad); }
.pos-txt { color: var(--ok); }
.neg-txt { color: var(--bad); }

button.chip-btn { font: inherit; font-weight: 500; cursor: pointer; padding: 6px 14px; border-radius: 99px; }
button.chip-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Procès-verbal ---------- */
.doc-pv { font-size: 10.5pt; line-height: 1.5; }
.doc-pv .pv-logo { position: absolute; top: 14mm; right: 15mm; height: 60px; }
.doc-pv .pv-title { font-size: 19pt; line-height: 1.15; font-weight: 800; margin: 18mm 0 10px; color: #111; letter-spacing: .01em; }
.doc-pv .pv-sub { color: #555; margin-bottom: 6px; }
.doc-pv .pv-org { font-size: 14pt; margin: 14px 0 4px; color: var(--accent); }
.doc-pv h3 { font-size: 12pt; margin: 16px 0 6px; color: #222; }
.doc-pv p { margin: 0 0 8px; }
.doc-pv .pv-info { margin: 0 0 8px; padding-left: 20px; }
.doc-pv .pv-agenda { margin: 0; padding-left: 22px; }
.doc-pv .pv-res { break-inside: avoid-page; }
.doc-pv .pv-res-t { margin-top: 12px; }
.doc-pv .pv-vote { margin-left: 28px; }
.doc-pv .pv-made { margin-top: 18px; }
.doc-pv .pv-signs { display: grid; grid-template-columns: repeat(auto-fill, minmax(70mm, 1fr)); gap: 14px 28px; margin-top: 10px; break-inside: avoid; }
.doc-pv .pv-signs > div { display: grid; gap: 2px; align-content: start; min-height: 30mm; }
.doc-pv .pv-signs span { color: #444; }
.doc-pv .pv-signs img { max-height: 22mm; max-width: 60mm; margin-top: 4px; }
.doc-pv .pv-signs em { color: #999; font-style: normal; font-family: ui-monospace, Menlo, monospace; font-size: 9pt; margin-top: 6px; }
.doc-pv .pv-signs small { color: #777; font-size: 7.5pt; }
.res-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; }
.res-card .res-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.signer-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 600px) { .signer-row { grid-template-columns: 1fr; } }
.sign-banner { display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin-bottom: 18px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 9%, var(--card)); border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent); color: var(--ink); text-decoration: none; }
.sign-banner > svg:first-child { color: var(--accent); flex: none; }
.sign-banner span { flex: 1; min-width: 0; }
.sign-banner small { display: block; color: var(--ink-3); margin-top: 2px; }
.res-card .res-head .actions { gap: 2px; }
