/* ==========================================================================
   Facturation prévisionnelle — feuille de style
   ========================================================================== */
:root {
  color-scheme: light;
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --surface-2: #FAFAF7;
  --ink: #16181C;
  --ink-2: #555A63;
  --ink-3: #8B909A;
  --line: #E5E3DD;
  --line-2: #EFEDE8;
  --accent: #0E7C61;        /* facturé */
  --accent-ink: #0A6450;
  --accent-soft: #E2F1EC;
  --prevu: #94A8F0;         /* prévu */
  --prevu-soft: #E9EDFC;
  --warn: #B5532B;
  --warn-soft: #F8E9E1;
  --now: #FFF7E3;
  --now-line: #E7C773;
  --shadow: 0 1px 2px rgba(22, 24, 28, .04), 0 4px 18px rgba(22, 24, 28, .04);
  --shadow-lg: 0 20px 60px rgba(22, 24, 28, .18);
  --radius: 14px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, ui-serif, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111214;
    --surface: #17181B;
    --surface-2: #1C1D21;
    --ink: #ECEDEF;
    --ink-2: #A5A9B2;
    --ink-3: #737882;
    --line: #2A2C31;
    --line-2: #222428;
    --accent: #2BA582;
    --accent-ink: #4CC29F;
    --accent-soft: #17332B;
    --prevu: #8095E8;
    --prevu-soft: #202640;
    --warn: #E08A62;
    --warn-soft: #3A2419;
    --now: #2A2516;
    --now-line: #8C7330;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--sans); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.num, .table-num td, .kpi-value, .grid td { font-variant-numeric: tabular-nums; }
.accent { color: var(--accent-ink); }
.r { text-align: right; }

/* ---------------------------------------------------------------- En-tête */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  height: 60px; padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; }
.bm-bg { fill: var(--ink); }
.bm-bar { fill: var(--surface); opacity: .55; }
.bm-accent { fill: #5FC4A8; opacity: 1; }
.nav { display: flex; gap: 2px; }
.nav a { white-space: nowrap; padding: 7px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.on { color: var(--ink); background: var(--line-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.ex-switch { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); }
.ex-switch > a { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--ink-2); font-size: 16px; }
.ex-switch > a:hover { background: var(--line-2); color: var(--ink); }
.ex-switch span { padding: 0 8px; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; }
.ex-switch small { font-weight: 500; color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.ex-switch a.ex-today { width: auto; padding: 0 9px; font-size: 12px; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); }

.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--surface); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.menu-pop { position: absolute; right: 0; top: 44px; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease-out; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; border: 0; background: none; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--line-2); }
.menu-who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-who span { color: var(--ink-3); font-size: 12.5px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }

/* ---------------------------------------------------------------- Page */
.page { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 36px 28px 48px; }
.page-wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; color: var(--ink-3); font-size: 12.5px; letter-spacing: .01em; }
.eyebrow a:hover { color: var(--ink); text-decoration: underline; }
h1 { margin: 0; font: 500 34px/1.1 var(--serif); letter-spacing: -.015em; }
h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.head-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--ink-3)); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--warn); }
.btn-danger-ghost:hover { background: var(--warn-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: progress; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; }
button.link:hover, .footer a:hover { color: var(--ink); text-decoration: underline; }

/* ---------------------------------------------------------------- Cartes & KPI */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-title { margin-bottom: 14px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi-value { font: 500 34px/1.1 var(--serif); letter-spacing: -.02em; white-space: nowrap; }
.kpi-value small { font-size: 22px; color: var(--ink-2); }
.kpi-sub { color: var(--ink-3); font-size: 12.5px; }

.meter { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin: 4px 0 2px; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter.thin { height: 4px; margin: 6px 0 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }

/* ---------------------------------------------------------------- Graphiques */
.legend { display: flex; gap: 14px; color: var(--ink-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw-prevu { background: var(--prevu); }
.sw-facture { background: var(--accent); }
.sw-line-prevu { height: 0; width: 16px; border-top: 2px dashed var(--prevu); border-radius: 0; }
.sw-line-facture { height: 0; width: 16px; border-top: 2px solid var(--accent); border-radius: 0; }
.chart { position: relative; height: 260px; }
.chart svg { display: block; overflow: visible; }
.chart .grid-l { stroke: var(--line-2); }
.chart .axis-l { stroke: var(--line); }
.chart .tick { fill: var(--ink-3); font-size: 11px; }
.chart .tick-now { fill: var(--ink); font-weight: 600; }
.chart .now-band { fill: var(--now); opacity: .75; }
.chart .bar-prevu { fill: var(--prevu); }
.chart .bar-facture { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.on { fill: color-mix(in srgb, var(--ink) 4%, transparent); }
.chart .hit-area { fill: transparent; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-prevu { stroke: var(--prevu); stroke-dasharray: 5 4; }
.chart .line-facture { stroke: var(--accent); }
.chart .area-prevu { fill: var(--prevu-soft); opacity: .6; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot-prevu { fill: var(--prevu); }
.chart .dot-facture { fill: var(--accent); }
.chart .direct { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .guide { stroke: var(--ink-3); stroke-dasharray: 2 3; opacity: 0; pointer-events: none; }
.tip { position: absolute; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 5; min-width: 190px;
  background: var(--ink); color: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 4px; }
.tip strong { font-weight: 600; text-transform: capitalize; margin-bottom: 2px; }
.tip span { display: flex; align-items: center; gap: 7px; }
.tip b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 14px; }
.tip .tip-sep { border-top: 1px solid color-mix(in srgb, var(--surface) 20%, transparent); padding-top: 5px; margin-top: 2px; opacity: .85; }

.data-table { margin: 0 0 16px; }
.data-table summary { cursor: pointer; color: var(--ink-3); font-size: 12.5px; padding: 2px 0 10px; width: max-content; }
.data-table summary:hover { color: var(--ink); }
.data-table .table { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }

/* ---------------------------------------------------------------- Listes */
.resp-list, .due-list { list-style: none; margin: 0; padding: 0; }
.resp-list li { padding: 10px 0; border-top: 1px solid var(--line-2); }
.resp-list li:first-child { border-top: 0; padding-top: 0; }
.resp-top { display: flex; align-items: center; gap: 10px; }
.resp-nom { font-weight: 550; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-avatar { display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); font-size: 10.5px; font-weight: 650; letter-spacing: .02em; vertical-align: middle; }
.chip-avatar.sm { width: 24px; height: 24px; font-size: 10px; margin-right: 4px; }
.due-list li a { display: flex; align-items: center; gap: 12px; padding: 9px 8px; margin: 0 -8px; border-radius: 9px; }
.due-list li a:hover { background: var(--surface-2); }
.due-list li + li a { border-top: 1px solid var(--line-2); border-radius: 0; }
.due-list li + li a:hover { border-radius: 9px; }
.due-date { flex: none; width: 58px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--line-2); border-radius: 6px; text-align: center; padding: 3px 0; }
.due-date.late { color: var(--warn); background: var(--warn-soft); }
.due-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.due-main strong { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-main small { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num.neg { color: var(--warn); }
.empty { color: var(--ink-3); margin: 4px 0; }
.empty.ok::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.badge { font-size: 11.5px; font-weight: 650; padding: 1px 8px; border-radius: 99px; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------------------------------------------------------------- Pastilles */
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; letter-spacing: .01em; vertical-align: 1px; white-space: nowrap; }
.pill-en_cours { background: var(--accent-soft); color: var(--accent-ink); }
.pill-prospect { background: var(--prevu-soft); color: color-mix(in srgb, var(--prevu) 55%, var(--ink)); }
.pill-terminee { background: var(--line-2); color: var(--ink-3); }
.pill-role-admin { background: var(--ink); color: var(--surface); }
.pill-role-editeur { background: var(--accent-soft); color: var(--accent-ink); }
.pill-role-lecteur { background: var(--line-2); color: var(--ink-2); }

/* ---------------------------------------------------------------- Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-num td + td, .table-num th + th { text-align: right; }
.table .r { text-align: right; }
.row-link { cursor: pointer; transition: background .12s; }
.row-link:hover { background: var(--surface-2); }
.row-link:hover .chev { color: var(--ink); transform: translateX(2px); }
.chev { color: var(--ink-3); font-size: 18px; transition: transform .15s, color .15s; display: inline-block; }
.aff-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aff-code { font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-2); margin-right: 7px; }
.progress-cell { display: inline-flex; flex-direction: column; align-items: flex-end; min-width: 110px; }
.progress-cell .meter { width: 100%; }
tr.inactive td { opacity: .5; }

/* ---------------------------------------------------------------- Planning */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button, .seg label span { border: 0; background: none; padding: 6px 14px; border-radius: 7px; font-weight: 550; color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; display: block; }
.seg button:hover, .seg label:hover span { color: var(--ink); }
.seg button.on, .seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 11px; width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 1.6; stroke-linecap: round; }
.search input, .select, .field input, .field textarea {
  height: 36px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.search input { padding-left: 34px; width: 280px; }
.select { padding-right: 30px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238B909A' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.search input:focus, .select:focus, .field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toolbar-hint { margin-left: auto; color: var(--ink-3); font-size: 12.5px; }
.save-state { font-size: 12.5px; font-weight: 550; min-width: 100px; text-align: right; }
.save-state.busy { color: var(--ink-3); }
.save-state.ok { color: var(--accent-ink); }
.save-state.ok::before { content: "✓ "; }
.save-state.err { color: var(--warn); }

.grid-wrap { position: relative; overflow: auto; max-height: calc(100vh - 250px); min-height: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overscroll-behavior: contain; }
.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid th, .grid td { padding: 0; border-bottom: 1px solid var(--line-2); background: var(--surface); }
.grid thead th { position: sticky; top: 0; z-index: 3; height: 42px; padding: 0 12px; font-size: 12px; font-weight: 600; color: var(--ink-3); text-align: right; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.grid th.sortable { cursor: pointer; }
.grid th.sortable:hover { color: var(--ink); }
.grid thead th.c-aff, .grid thead th.c-resp { text-align: left; }
.grid thead th.now { color: var(--ink); background: var(--now); box-shadow: inset 0 -2px 0 var(--now-line); }
.grid .c-aff { position: sticky; left: 0; z-index: 2; width: 300px; min-width: 300px; max-width: 300px; }
.grid .c-resp { position: sticky; left: 300px; z-index: 2; width: 56px; min-width: 56px; text-align: center; border-right: 1px solid var(--line); }
.grid thead .c-aff, .grid thead .c-resp, .grid tfoot .c-aff, .grid tfoot .c-resp { z-index: 4; }
.grid .c-m { width: 108px; min-width: 108px; text-align: right; }
.grid .c-tot { width: 140px; min-width: 140px; text-align: right; padding: 0 16px; font-weight: 600; border-left: 1px solid var(--line); white-space: nowrap; }
.grid td.c-m.now { background: color-mix(in srgb, var(--now) 55%, var(--surface)); }
.grid td.c-m.past { background: var(--surface-2); }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface)); }
.grid tbody tr.flash td { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } }
.grid tbody tr.st-terminee .aff-nom { color: var(--ink-3); }

.aff { display: flex; align-items: center; gap: 8px; padding: 9px 10px 9px 16px; min-height: 52px; }
.aff-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.aff-nom { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aff-client { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aff-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
tr:hover .aff-actions, .aff-actions:focus-within { opacity: 1; }
.icon-btn { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

.cell { width: 100%; height: 52px; border: 0; background: transparent; text-align: right; padding: 0 12px; outline: none; font-variant-numeric: tabular-nums; transition: background .2s, box-shadow .15s; border-radius: 0; }
.cell::placeholder { color: color-mix(in srgb, var(--ink-3) 55%, transparent); }
.cell:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.cell:focus { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); border-radius: 4px; position: relative; z-index: 1; }
.cell.saved { background: var(--accent-soft); }
.cell.invalid { background: var(--warn-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.ro { display: block; padding: 0 12px; line-height: 52px; }
.grid[data-vue="facture"] .cell:not(:placeholder-shown), .grid[data-vue="facture"] .ro { color: var(--accent-ink); font-weight: 550; }

.cmp { padding: 7px 12px; display: grid; grid-template-columns: 1fr; justify-items: end; line-height: 1.25; }
.cmp-f { font-weight: 600; }
.cmp-p { font-size: 11.5px; color: var(--ink-3); }
.cmp-bar { width: 100%; height: 3px; border-radius: 9px; background: var(--line-2); margin-top: 4px; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; background: var(--prevu); border-radius: inherit; }
.cmp.done .cmp-bar i, .cmp.over .cmp-bar i { background: var(--accent); }
.cmp.done .cmp-f, .cmp.over .cmp-f { color: var(--accent-ink); }
.cmp.late .cmp-f { color: var(--warn); }
.cmp.late .cmp-bar i { background: var(--warn); }
.cmp.future { padding: 0 12px; line-height: 52px; display: block; }
.cmp.future .cmp-p { font-size: 13px; }
.cmp-empty { display: block; padding: 0 12px; color: var(--line); line-height: 52px; }

.grid tfoot td { position: sticky; z-index: 2; background: var(--surface-2); font-weight: 600; padding: 0 12px; height: 44px; white-space: nowrap; }
.grid tfoot tr:first-child td { bottom: 34px; border-top: 1px solid var(--line); border-bottom: 0; }
.grid tfoot tr.cumul td { bottom: 0; height: 34px; font-weight: 500; font-size: 12px; color: var(--ink-3); border-bottom: 0; }
.grid tfoot .c-aff { padding-left: 16px; }
.grid tfoot td.c-m.now { background: var(--now); }
.tot-f, .tot-p { display: block; line-height: 1.25; }
.tot-p { font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.grid-empty { padding: 60px 20px; text-align: center; }
.grid-empty p { margin: 4px; }
.grid.is-empty tfoot { display: none; }

/* ---------------------------------------------------------------- Formulaires */
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.form-card { display: flex; flex-direction: column; gap: 18px; padding: 26px; }
.form-card fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.form-card.narrow { max-width: 460px; }
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; min-width: 0; }
.form-row > .w-sm { flex: 0 0 150px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.field textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field .select { width: 100%; }
.seg-form { width: 100%; }
.seg-form label { flex: 1; text-align: center; position: relative; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.side { display: flex; flex-direction: column; gap: 12px; }
.stats { margin: 0 0 12px; display: grid; gap: 10px; }
.stats div { display: flex; justify-content: space-between; align-items: baseline; }
.stats dt { color: var(--ink-2); }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.side .btn-block { margin-top: 10px; }
.empty-state { text-align: center; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state h2 { font: 500 24px var(--serif); }
.roles-help { display: flex; gap: 24px; margin: -8px 0 18px; color: var(--ink-3); font-size: 12.5px; flex-wrap: wrap; }
.roles-help strong { color: var(--ink-2); margin-right: 6px; font-weight: 600; }

/* ---------------------------------------------------------------- Dialogues */
.dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); width: min(460px, calc(100vw - 32px)); text-align: left; }
.dialog::backdrop { background: rgba(17, 18, 20, .35); backdrop-filter: blur(3px); }
.dialog[open] { animation: dlg .18s cubic-bezier(.2, .8, .2, 1); }
@keyframes dlg { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-body { padding: 26px; display: flex; flex-direction: column; gap: 16px; }
.dialog-body h2 { font: 500 22px var(--serif); }
.dialog-body p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.drop { position: relative; display: grid; place-items: center; height: 110px; border: 1.5px dashed var(--line); border-radius: 12px; color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.update-status { min-height: 20px; font-size: 13px; }
.update-status.busy { color: var(--ink-2); }
.update-status.err { color: var(--warn); }
.month-picks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.mp { position: relative; }
.mp input { position: absolute; opacity: 0; }
.mp span { display: block; text-align: center; padding: 6px 0; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; cursor: pointer; transition: all .12s; }
.mp input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.mp input:focus-visible + span { outline: 2px solid var(--accent); }

/* ---------------------------------------------------------------- Notifications */
.toasts { position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease-out; transition: opacity .5s, transform .5s; }
.toast-ok::before { content: "✓  "; color: #5FC4A8; }
.toast-erreur { background: var(--warn); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-6px); }

/* ---------------------------------------------------------------- Connexion */
.login-body .page { display: grid; place-items: center; max-width: none; padding: 24px; }
.login { display: grid; grid-template-columns: 1fr 1fr; width: min(900px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden; }
.login-art { background: var(--ink); padding: 48px 40px 36px; display: flex; flex-direction: column; justify-content: flex-end; }
.login-bars { width: 100%; height: auto; }
.lb-on { fill: #5FC4A8; }
.lb-off { fill: none; stroke: #94A8F0; stroke-width: 1.5; stroke-dasharray: 3 3; }
.login-months { display: flex; justify-content: space-between; color: rgba(255, 255, 255, .5); font-size: 12px; margin-top: 10px; }
.login-card { padding: 56px 48px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 30px; }
.login-card p { margin: -6px 0 8px; }
.login-card .btn { height: 42px; margin-top: 6px; }
.login-card .field input { height: 42px; }

/* ---------------------------------------------------------------- Pied de page */
.footer { display: flex; justify-content: space-between; gap: 16px; padding: 18px 28px 24px; color: var(--ink-3); font-size: 12.5px; border-top: 1px solid var(--line-2); }
.footer-actions { display: flex; gap: 18px; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .nav a { padding: 7px 9px; }
}
@media (max-width: 820px) {
  .topbar { gap: 12px; padding: 0 14px; overflow-x: auto; }
  .brand span { display: none; }
  .page { padding: 24px 14px 36px; }
  h1 { font-size: 28px; }
  .grid-2, .grid-3, .form-layout, .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
  .toolbar-hint { display: none; }
  .grid .c-aff { width: 190px; min-width: 190px; max-width: 190px; }
  .grid .c-resp { left: 190px; }
  .form-row { flex-direction: column; }
  .form-row > .w-sm { flex: 1; }
  .ex-switch small { display: none; }
}
@media (max-width: 540px) {
  .kpis { grid-template-columns: 1fr; }
  .table-affaires th:nth-child(3), .table-affaires td:nth-child(3), .table-affaires th:nth-child(4), .table-affaires td:nth-child(4) { display: none; }
}
@media print {
  .topbar, .footer, .toolbar, .head-actions, .aff-actions { display: none !important; }
  .grid-wrap { max-height: none; overflow: visible; box-shadow: none; }
  body { background: #fff; }
}
