/* Budget Événements — PBI
   Mise en page : barre latérale noire (charte pbi) + espace de travail clair ; or réservé aux repères. */

@font-face { font-family: "Figtree"; src: url("fonts/Figtree-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/Figtree-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("fonts/Figtree-SemiBold.ttf") format("truetype"); font-weight: 600 700; font-display: swap; }

:root {
  --ink: #231f20;
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #f8f7f5;
  --line: #e4e0d9;
  --line-strong: #cfc9bf;
  --muted: #6e6862;
  --faint: #9a938b;
  --gold: #e0bf78;
  --gold-ink: #86692c;
  --gold-soft: #f6edd9;
  --ok: #2c7a52;
  --ok-soft: #e3f1e9;
  --warn: #a9701a;
  --warn-soft: #fbefd9;
  --bad: #b2372e;
  --bad-soft: #f8e3e0;
  --side: #1b1819;
  --side-ink: #d9d4cc;
  --side-muted: #8e877f;
  --s-estime: #dcd7cf;
  --s-devis: #efe0bd;
  --s-engage: #e0bf78;
  --s-facture: #8b7f72;
  --s-paye: #231f20;
  --focus: #b98d2e;
  --shadow: 0 1px 2px rgba(35,31,32,.05), 0 8px 24px rgba(35,31,32,.06);
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 4px;
  --r-sm: 3px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eeeae4; --bg: #121011; --surface: #1c191a; --surface-2: #221f20; --line: #322e2c; --line-strong: #47423f;
    --muted: #a7a098; --faint: #7b746d; --gold: #e0bf78; --gold-ink: #e6c98a; --gold-soft: #3a3121;
    --ok: #5fbf8c; --ok-soft: #17301f; --warn: #e2a64a; --warn-soft: #36290f; --bad: #ef7a6f; --bad-soft: #3b1a17;
    --side: #0b0a0a; --side-ink: #d9d4cc; --side-muted: #8a837b;
    --s-estime: #3e3936; --s-devis: #6a5a35; --s-engage: #c8a65e; --s-facture: #a2968a; --s-paye: #eeeae4;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #eeeae4; --bg: #121011; --surface: #1c191a; --surface-2: #221f20; --line: #322e2c; --line-strong: #47423f;
  --muted: #a7a098; --faint: #7b746d; --gold: #e0bf78; --gold-ink: #e6c98a; --gold-soft: #3a3121;
  --ok: #5fbf8c; --ok-soft: #17301f; --warn: #e2a64a; --warn-soft: #36290f; --bad: #ef7a6f; --bad-soft: #3b1a17;
  --side: #0b0a0a; --side-ink: #d9d4cc; --side-muted: #8a837b;
  --s-estime: #3e3936; --s-devis: #6a5a35; --s-engage: #c8a65e; --s-facture: #a2968a; --s-paye: #eeeae4;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.boot { padding: 48px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px; gap: 18px; }
.side .brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; text-decoration: none; }
.side .brand img { width: 64px; height: auto; }
.side .brand span { font-size: 12px; line-height: 1.3; color: var(--side-muted); border-left: 1px solid #3a3533; padding-left: 12px; }
.side .brand strong { display: block; color: #fff; font-weight: 600; font-size: 13px; }
.ev-switch { text-decoration: none; width: 100%; text-align: left; background: transparent; border: 1px solid #36312f; border-radius: 3px; padding: 10px 12px; color: #fff; cursor: pointer; display: grid; gap: 2px; }
.ev-switch:hover { border-color: #57504b; }
.ev-switch small { color: var(--side-muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.ev-switch b { font-weight: 600; font-size: 14px; line-height: 1.3; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 3px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .75; }
.nav a:hover { background: #262223; }
.nav a[aria-current="page"] { background: #2d2828; color: #fff; }
.nav a[aria-current="page"] svg { opacity: 1; color: var(--gold); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--side-muted); font-variant-numeric: tabular-nums; }
.side .sep { height: 1px; background: #2e2a29; margin: 2px 8px; }
.side .foot { margin-top: auto; display: grid; gap: 2px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 3px; text-decoration: none; color: var(--side-ink); }
.me:hover { background: #262223; }
.me small { display: block; color: var(--side-muted); font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #3a3533; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; letter-spacing: .02em; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.ghost { background: transparent; border: 1px dashed var(--line-strong); color: var(--muted); }

.main { min-width: 0; padding-block: 28px 64px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.wrap > *, .stack > *, .grid-2 > * { min-width: 0; }
.topbar { display: none; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 24px; line-height: 1.25; }
.page-head .crumb { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.page-head .meta-line { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.dot-sep { margin: 0 8px; color: var(--faint); }
.page-head .sub { margin-top: 6px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--gold-soft); color: var(--gold-ink); letter-spacing: 0; text-transform: none; }
.chip.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card > header h2 { font-size: 15px; }
.card > header p { color: var(--muted); font-size: 13px; }
.card .body { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.stack { display: grid; gap: 22px; min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 4px; min-width: 0; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .02em; }
.kpi .value { font-size: 25px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--faint); margin-left: 4px; }
.kpi .meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi.main-kpi { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.kpi.main-kpi .label, .kpi.main-kpi .meta { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.kpi.main-kpi .value small { color: color-mix(in srgb, var(--bg) 55%, transparent); }

/* Jauge de consommation */
.gauge { padding: 20px; display: grid; gap: 18px; }
.gauge-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.gauge-top h2 { font-size: 15px; }
.gauge-track { position: relative; height: 34px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); overflow: visible; }
.gauge-fill { position: absolute; inset: 0; display: flex; border-radius: 5px; overflow: hidden; }
.gauge-fill span { height: 100%; transition: width .5s ease; }
.gauge-marker { position: absolute; top: -8px; bottom: -8px; width: 2px; background: var(--ink); }
.gauge-marker b { position: absolute; top: -22px; transform: translateX(-50%); left: 1px; font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--ink); }
.gauge-marker b.end { transform: translateX(-100%); }
.gauge-over { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(-45deg, var(--bad) 0 4px, transparent 4px 8px); opacity: .5; border-radius: 0 5px 5px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .num { font-weight: 600; }
.legend .muted { font-size: 12px; }

.s-estime { background: var(--s-estime); }
.s-devis { background: var(--s-devis); }
.s-engage { background: var(--s-engage); }
.s-facture { background: var(--s-facture); }
.s-paye { background: var(--s-paye); }

/* Postes */
.posts { display: grid; }
.post { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) auto; gap: 8px 20px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); text-decoration: none; }
.post:first-child { border-top: 0; }
a.post:hover { background: var(--surface-2); }
.post .name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.post .name { flex-wrap: wrap; gap: 2px 8px; }
.post .name span { overflow-wrap: anywhere; }
.post .name small { font-weight: 400; color: var(--faint); font-size: 12px; white-space: nowrap; }
.post .bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); }
.post .bar > span { position: absolute; top: -1px; bottom: -1px; left: -1px; border-radius: 5px; }
.post .bar .fc { background: var(--s-devis); }
.post .bar .en { background: var(--s-engage); }
.post .bar .pa { background: var(--s-paye); }
.post .bar.over { border-color: var(--bad); }
.post .figs { display: flex; gap: 18px; justify-content: flex-end; font-size: 13px; }
.post .figs div { display: grid; text-align: right; min-width: 88px; }
.post .figs small { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.post .figs b { font-weight: 600; }
.post .figs .gap-pos { color: var(--ok); }
.post .figs .gap-neg { color: var(--bad); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.none { color: var(--muted); background: var(--surface-2); }
.st { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.st i { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* Fil d'activité */
.feed { display: grid; }
.feed-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 13px 20px; border-top: 1px solid var(--line); }
.feed-item:first-child { border-top: 0; }
.feed-item .avatar { width: 30px; height: 30px; font-size: 11px; }
.feed-item p { font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.feed-item .when { font-size: 12px; color: var(--faint); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.changes { margin-top: 6px; display: grid; gap: 3px; font-size: 12.5px; }
.changes div { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.changes span:first-child { color: var(--faint); }
.changes s { color: var(--faint); }
.mailed { display: inline-flex; gap: 4px; align-items: center; color: var(--faint); }
.mailed svg { width: 13px; height: 13px; }

.watch { display: grid; }
.watch-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 20px; border-top: 1px solid var(--line); text-decoration: none; }
.watch-item:first-child { border-top: 0; }
a.watch-item:hover { background: var(--surface-2); }
.watch-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; }
.watch-item b { font-weight: 600; }
.watch-item div { min-width: 0; font-size: 13px; }
.empty { padding: 28px 20px; color: var(--muted); text-align: center; font-size: 13px; display: grid; gap: 10px; justify-items: center; }
.empty strong { color: var(--ink); font-size: 15px; }

/* ---------- Boutons et champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface); padding: 8px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.3; }
.btn:hover { border-color: var(--ink); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--gold)); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #231f20; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 7px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); }
.input, select.input, textarea.input { width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 3px; padding: 9px 11px; font-size: 14px; min-width: 0; }
textarea.input { min-height: 78px; resize: vertical; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 30%, transparent); }
.input.money { text-align: right; font-variant-numeric: tabular-nums; }
.input[readonly] { background: var(--surface-2); }
.input-affix { position: relative; }
.input-affix .input { padding-right: 34px; }
.input-affix span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 13px; pointer-events: none; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1.2fr .8fr 1.2fr; gap: 12px; }
.form { display: grid; gap: 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.error-box { background: var(--bad-soft); color: var(--bad); border-radius: 3px; padding: 10px 12px; font-size: 13px; font-weight: 500; }
.info-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: flex-start; }
.info-box svg { width: 18px; height: 18px; flex: none; color: var(--gold-ink); margin-top: 1px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 3px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.seg button i { width: 8px; height: 8px; border-radius: 2px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 600; }
.seg.full { display: grid; grid-template-columns: repeat(5, 1fr); }
.seg.full button { justify-content: center; padding: 8px 4px; }

.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-strong); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled { cursor: default; }
.switch input:disabled + span { opacity: .5; }

/* ---------- Tableau des dépenses ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 220px; position: relative; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.toolbar .search .input { padding-left: 34px; }
.toolbar select.input { width: auto; max-width: 240px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
table.data th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.data th button:focus-visible { outline: 2px solid var(--focus); }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr.sel td { background: var(--gold-soft); }
table.data .r { text-align: right; }
table.data td.lbl b { font-weight: 600; display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.lbl small { color: var(--faint); font-size: 12.5px; }
table.data tfoot td { font-weight: 600; border-bottom: 0; background: var(--surface-2); }
.clip { display: inline-flex; gap: 3px; align-items: center; color: var(--muted); font-size: 12px; }
.clip svg { width: 14px; height: 14px; }
.tag-nf { font-size: 11px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }

/* ---------- Tiroir et fenêtres ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20,17,18,.42); z-index: 40; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 41; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(0,0,0,.18); animation: slide .2s ease; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.drawer > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.drawer > header h2 { font-size: 18px; }
.drawer > header p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.drawer .content { flex: 1; overflow-y: auto; padding: 20px 24px 28px; display: grid; gap: 22px; align-content: start; }
.drawer > footer { border-top: 1px solid var(--line); padding: 14px 24px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); }
.drawer > footer .note { font-size: 12px; color: var(--faint); flex: 1 1 180px; display: flex; gap: 6px; align-items: center; }
.drawer > footer .note svg { width: 14px; height: 14px; flex: none; }
.section-title { font-size: 13px; color: var(--ink); font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.total-line b { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }

.modal { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; background: var(--surface); border-radius: 6px; box-shadow: 0 24px 64px rgba(0,0,0,.25); animation: pop .18s ease; }
.modal > header { padding: 20px 24px 6px; }
.modal > header h2 { font-size: 18px; }
.modal > header p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.modal .content { padding: 14px 24px 20px; }
.modal footer { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.scrim.top { z-index: 50; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -48%); opacity: 0; } }

.files { display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px; }
.file .ext { width: 36px; height: 36px; border-radius: 3px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); display: grid; place-items: center; font-size: 10.5px; font-weight: 700; text-transform: uppercase; flex: none; letter-spacing: .03em; }
.file a { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.file a:hover { text-decoration: underline; }
.file div { min-width: 0; flex: 1; }
.file small { color: var(--faint); font-size: 12px; }
.file.pending { border-style: dashed; }
.drop { border: 1px dashed var(--line-strong); border-radius: 4px; padding: 16px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; display: grid; gap: 4px; }
.drop:hover, .drop.over { border-color: var(--gold-ink); background: var(--gold-soft); color: var(--ink); }
.drop b { color: var(--ink); }

/* ---------- Budget ---------- */
.budget-table td.name { min-width: 220px; width: 32%; }
.budget-table td .input-affix { width: 150px; margin-left: auto; }
.budget-table td.name .input { max-width: none; font-weight: 600; }
.budget-table tbody tr { cursor: default; }
.budget-table tbody tr:hover td { background: transparent; }
.savebar { position: sticky; bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--ink); color: var(--bg); padding: 12px 16px 12px 20px; border-radius: 4px; box-shadow: var(--shadow); flex-wrap: wrap; }
.savebar .btn { border-color: transparent; }
.savebar .btn:not(.gold) { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }

/* ---------- Équipe ---------- */
.people { display: grid; }
.person { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person .who b { display: block; font-weight: 600; }
.person .who small { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.person .notif { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.person select.input { width: auto; padding: 6px 9px; font-size: 13px; }
.roles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.roles div { border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.roles b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- Journal ---------- */
.day { padding: 9px 20px; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.day:first-child { border-top: 0; }

/* ---------- Évènements ---------- */
.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.event-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 14px; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.event-card:hover { border-color: var(--ink); }
.event-card h3 { font-size: 17px; }
.event-card .meta { color: var(--muted); font-size: 13px; }
.event-card .figs { display: flex; justify-content: space-between; font-size: 13px; }
.event-card .figs b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.event-card.archived { opacity: .6; }
.mini-bar { height: 8px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); position: relative; overflow: hidden; }
.mini-bar span { position: absolute; top: 0; bottom: 0; left: 0; }

/* ---------- Authentification ---------- */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.auth-bar { background: var(--side); color: #fff; display: flex; align-items: center; gap: 14px; padding: 14px max(24px, env(safe-area-inset-right, 0px)) 14px max(24px, env(safe-area-inset-left, 0px)); margin-top: calc(-1 * env(safe-area-inset-top, 0px)); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.auth-bar img { width: 52px; }
.auth-bar span { font-weight: 600; font-size: 14px; border-left: 1px solid #3a3533; padding-left: 14px; }
.auth-main { display: grid; place-items: start center; padding: 72px max(20px, env(safe-area-inset-right, 0px)) 40px max(20px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(380px, 100%); display: grid; gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 28px; }
.auth-card h2 { font-size: 20px; }
.auth-card .lead { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.auth-card .links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.auth-card .links a { color: var(--ink); }
.auth-foot { text-align: center; color: var(--faint); font-size: 12px; padding: 20px; }

/* ---------- Notifications à l'écran ---------- */
#toasts { position: fixed; z-index: 60; bottom: max(20px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(480px, calc(100vw - 32px)); }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 4px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow); animation: pop2 .2s ease; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--bad); color: #fff; }
.toast svg { width: 16px; height: 16px; flex: none; color: var(--gold); }
@keyframes pop2 { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Impression ---------- */
@media print {
  .side, .topbar, .actions, .toolbar, .no-print, #toasts, .savebar { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .card, .kpi { break-inside: avoid; border-color: #ccc; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Écrans étroits ---------- */
@media (max-width: 1320px) { table.data .hide-md { display: none; } }
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 45; transform: translateX(-100%); transition: transform .2s ease; padding-top: calc(22px + env(safe-area-inset-top, 0px)); padding-left: max(14px, env(safe-area-inset-left, 0px)); }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.4); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--side); color: #fff; padding: 10px max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px)); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 31; background: var(--side); }
  .topbar img { width: 44px; }
  .topbar .icon-btn { color: #fff; }
  .topbar .icon-btn:hover { background: #2d2828; color: #fff; }
  .topbar b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .main { padding-block: 20px 56px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .post { grid-template-columns: minmax(0, 1fr); }
  .post .figs { justify-content: space-between; }
  .post .figs div { min-width: 0; }
  .person { grid-template-columns: 40px minmax(0, 1fr) auto; }
  .person .notif, .person .role-cell { grid-column: 2 / -1; }
  .roles { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { padding: 32px max(24px, env(safe-area-inset-left, 0px)) 28px; gap: 20px; }
  .auth-side h1 { font-size: 26px; }
  .auth-side .ledger, .auth-side small { display: none; }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .row-3 > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 23px; }
  .seg.full { grid-template-columns: repeat(3, 1fr); }
  .drawer .content, .drawer > header, .drawer > footer { padding-left: 18px; padding-right: 18px; }
  table.data .hide-sm { display: none; }
  .post .figs div:nth-child(2) { display: none; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Version sobre : synthèse, tableau des postes, journal ---------- */
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.sum-cells { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.sum-cell { padding: 16px 18px; display: grid; gap: 2px; align-content: start; background: var(--surface); min-width: 0; }
.sum-label { font-size: 13px; color: var(--muted); }
.sum-value { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.sum-note { font-size: 12.5px; color: var(--faint); }
.sum-value.pos { color: var(--ok); }
.sum-value.neg, .neg { color: var(--bad); }
.warn { color: var(--warn); }
.sum-bar { padding: 14px 18px 16px; display: grid; gap: 10px; }
.sum-bar .gauge-track { height: 12px; border-radius: 2px; }
.sum-bar .gauge-fill { border-radius: 1px; }
.sum-bar .gauge-marker { top: -5px; bottom: -5px; }
.legend { gap: 6px 18px; }
.legend div { font-size: 12.5px; color: var(--muted); gap: 6px; }
.legend .num { color: var(--ink); font-weight: 500; }
.legend i { border-radius: 1px; }
.legend i.tick { width: 2px; height: 12px; background: var(--ink); }
.posts-table tbody td:first-child { font-weight: 500; }
.posts-table td.cons { width: 190px; }
.posts-table td.cons { white-space: nowrap; }
.meter { display: inline-block; vertical-align: middle; width: 110px; height: 6px; background: var(--surface-2); border: 1px solid var(--line); position: relative; margin-right: 10px; }
.meter span { position: absolute; inset: -1px auto -1px -1px; background: var(--ink); }
.meter span.warn { background: var(--warn); }
.meter span.neg { background: var(--bad); }
.pct { font-size: 13px; }
.grid-2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13.5px; }
.notes li { border-left: 2px solid var(--line-strong); padding: 1px 0 1px 10px; color: var(--ink); }
.notes li.neg { border-color: var(--bad); }
.notes li.warn { border-color: var(--warn); }
.notes a { text-decoration: none; }
.notes a:hover { text-decoration: underline; }
.empty-line { color: var(--muted); font-size: 13.5px; padding: 4px 0; }
.feed .empty-line { padding: 16px 20px; }
.feed-item { grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 12px 20px; }
.feed-time { font-size: 13px; color: var(--muted); display: grid; align-content: start; }
.feed-time small { font-size: 12px; color: var(--faint); }
.feed-body p { font-size: 13.5px; }
.feed-body p b { font-weight: 600; }
.feed-meta { color: var(--faint); font-size: 12px !important; margin-top: 3px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 6px; border-radius: 2px; border: 1px solid currentColor; line-height: 1.5; white-space: nowrap; }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--bad); }
.tag.none { color: var(--muted); }
.start h2 { font-size: 16px; margin-bottom: 8px; }
.start ol { margin: 0 0 16px; padding-left: 20px; color: var(--muted); display: grid; gap: 4px; }
.start-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card > header h2 .faint { font-weight: 400; }
@media (max-width: 1100px) { .grid-2.even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .sum-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sum-cell:last-child { grid-column: 1 / -1; } .posts-table td.cons { width: auto; } .meter { width: 60px; } }

/* ---------- Archives ---------- */
.archived-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2); font-size: 13.5px; color: var(--muted); }
.archived-bar span { display: flex; align-items: center; gap: 8px; }
.archived-bar svg { width: 16px; height: 16px; flex: none; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 12px; }
.danger-zone { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 24px; align-items: center; }
.danger-zone p { font-size: 13px; margin-top: 2px; }
.meta-line a { color: var(--ink); margin-left: 8px; }
@media (max-width: 560px) { .danger-zone { grid-template-columns: minmax(0, 1fr); } .danger-zone .btn { justify-self: start; } }

/* ---------- Menu Exporter ---------- */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { border-color: var(--ink); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 320px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; display: grid; }
.menu-pop a, .menu-pop button { display: grid; gap: 2px; text-align: left; padding: 9px 10px; border-radius: 3px; text-decoration: none; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover, .menu-pop a:focus-visible, .menu-pop button:focus-visible { background: var(--surface-2); }
.menu-pop b { font-weight: 600; font-size: 13.5px; }
.menu-pop small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.menu-pop button { border-top: 1px solid var(--line); border-radius: 0 0 3px 3px; margin-top: 4px; }

/* ---------- Photos d'évènement (assombries sur noir) ---------- */
img.cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .42; pointer-events: none; }
.event-card { position: relative; overflow: hidden; }
.event-card.has-cover { background: #000; border-color: #000; color: #fff; }
.event-card.has-cover > :not(.cover) { position: relative; }
.event-card.has-cover h3 { color: #fff; }
.event-card.has-cover .meta, .event-card.has-cover .muted, .event-card.has-cover .faint { color: rgba(255,255,255,.78); }
.event-card.has-cover .mini-bar { background: rgba(255,255,255,.16); border-color: transparent; }
.event-card.has-cover .mini-bar .s-paye { background: #fff; }
.event-card.has-cover .card-actions { border-top-color: rgba(255,255,255,.2); }
.event-card.has-cover:hover { border-color: var(--gold); }
.event-card.has-cover:hover img.cover { opacity: .5; }
img.cover { transition: opacity .2s; }

.page-head.hero { position: relative; overflow: visible; background: #000; color: #fff; border-radius: var(--r); padding: 56px 28px 24px; }
.page-head.hero > :not(.cover) { position: relative; }
.page-head.hero img.cover { border-radius: inherit; }
.menu-pop.left { right: auto; left: 0; }
.page-head.hero .actions { z-index: 5; }
.page-head.hero h1 { color: #fff; font-size: 28px; }
.page-head.hero .meta-line { color: rgba(255,255,255,.8); }
.page-head.hero .actions .btn:not(.primary) { background: rgba(255,255,255,.94); border-color: transparent; color: var(--s-paye); }
.page-head.hero .actions .btn.primary { background: var(--gold); border-color: var(--gold); color: #231f20; }

.ev-switch { position: relative; overflow: hidden; }
.ev-switch > :not(.cover) { position: relative; }
.ev-switch.has-cover { background: #000; border-color: #000; min-height: 64px; align-content: end; }
.ev-switch.has-cover small { color: rgba(255,255,255,.75); }

.photo-pick { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.photo-prev { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: var(--r); background: #231f20; display: flex; align-items: flex-end; padding: 12px; color: #fff; }
.photo-prev:not(.has-cover) { background: repeating-linear-gradient(135deg, #2b2627 0 10px, #231f20 10px 20px); }
.photo-prev > :not(.cover) { position: relative; }
.photo-prev b { font-size: 14px; font-weight: 600; }
.photo-prev.wide { aspect-ratio: 3 / 2; align-items: center; justify-content: center; }
.photo-prev .mini-card { width: 34%; height: 46%; background: #fff; border-radius: 2px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.photo-side { display: grid; gap: 10px; }
.photo-side .hint { margin: 0; }
@media (max-width: 640px) { .photo-pick { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Page de connexion avec image de fond ---------- */
.auth { position: relative; }
.auth.has-bg { background: #000; }
.auth-bg { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; pointer-events: none; }
.auth.has-bg > :not(.auth-bg) { position: relative; z-index: 1; }
.auth.has-bg .auth-bar { background: transparent; }
.auth.has-bg .auth-bar span { border-left-color: rgba(255,255,255,.35); }
.auth.has-bg .auth-card { border-color: transparent; box-shadow: 0 24px 64px rgba(0,0,0,.35); }
.auth.has-bg .auth-foot { color: rgba(255,255,255,.7); }
.preview-bar { background: var(--gold); color: #231f20; font-size: 13px; font-weight: 600; padding: 8px 20px; display: flex; gap: 16px; justify-content: center; }
.preview-bar a { color: #231f20; }
.event-card.has-cover .btn:not(.danger) { color: var(--ink); }

/* Lecture automatique des justificatifs */
.scan-drop { display: flex; gap: 14px; align-items: center; padding: 14px 16px; margin-bottom: 18px; border: 1.5px dashed color-mix(in srgb, var(--gold) 70%, var(--line)); border-radius: 6px; background: color-mix(in srgb, var(--gold-soft) 55%, transparent); cursor: pointer; transition: background .15s, border-color .15s; }
.scan-drop:hover, .scan-drop.over { background: var(--gold-soft); border-color: var(--gold); }
.scan-drop b { display: block; font-size: 14px; }
.scan-drop small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; line-height: 1.45; }
.scan-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #231f20; color: var(--gold); }
.scan-ico svg { width: 20px; height: 20px; }
.scan-drop.busy { cursor: progress; pointer-events: none; }
.scan-drop.busy .scan-ico { background: transparent; border: 2px solid var(--line); border-top-color: var(--gold); animation: spin .9s linear infinite; }
.scan-drop.busy .scan-ico svg { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#scan-note { margin: -6px 0 18px; }
.warn-box { background: var(--warn-soft); border-radius: 4px; padding: 12px 14px; font-size: 13px; color: var(--ink); display: flex; gap: 10px; align-items: flex-start; }
.warn-box svg { width: 18px; height: 18px; flex: none; color: var(--warn); margin-top: 1px; }
.input.ai-filled { background: color-mix(in srgb, var(--gold-soft) 70%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 75%, var(--line)); }

/* Renommer l'évènement (à côté du titre du tableau de bord) */
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row h1 { margin: 0; }
.btn.rename-ev svg { width: 14px; height: 14px; }
.page-head.hero .btn.rename-ev { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); color: #fff; }
.page-head.hero .btn.rename-ev:hover { background: rgba(255,255,255,.24); }
@media print { .btn.rename-ev { display: none; } }
