:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #1b2430;
  --muted: #637083;
  --border: #dde3ea;
  --primary: #1f5fa8;
  --primary-ink: #ffffff;
  --primary-soft: #e3edf9;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --warn: #9a6100;
  --warn-soft: #fff4dc;
  --ok: #1e7a4f;
  --ok-soft: #e1f4ea;
  --wait: #7a4bb0;
  --wait-soft: #f0e8fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
  --sidebar: #1f3a5f;
  --sidebar-ink: #dbe6f3;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --surface: #1a212b;
    --surface-2: #222b37;
    --text: #e6ebf1;
    --muted: #97a3b3;
    --border: #2d3846;
    --primary: #5c9ce6;
    --primary-ink: #0d1520;
    --primary-soft: #1d3149;
    --danger: #ef7a6c;
    --danger-soft: #3a2220;
    --warn: #f0b64d;
    --warn-soft: #362a14;
    --ok: #5fcf97;
    --ok-soft: #173427;
    --wait: #b99af0;
    --wait-soft: #2b2340;
    --shadow: none;
    --sidebar: #151c26;
    --sidebar-ink: #c6d3e2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }

.ico { width: 18px; height: 18px; flex: none; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .5rem .95rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; justify-content: flex-start; }
.btn.ghost:hover { background: rgba(255, 255, 255, .08); }
.btn.small { min-height: 32px; padding: .3rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn .ico { width: 16px; height: 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { background: var(--surface-2); }

.link-btn { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.stack { display: grid; gap: .5rem; }
.spacer { flex: 1; }

/* ---------- Formulaires ---------- */

label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .8rem; }
label > input, label > select, label > textarea { margin-top: .3rem; }

input, select, textarea {
  display: block; width: 100%;
  min-height: 40px; padding: .5rem .65rem;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 400;
}
textarea { resize: vertical; min-height: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .mrow:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
input:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--danger); }

.check { display: flex; align-items: flex-start; gap: .6rem; font-weight: 400; color: var(--text); font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin: .1rem 0 0; flex: none; accent-color: var(--primary); }
.check.inline { margin: 0; align-items: center; white-space: nowrap; }

fieldset { border: 1px solid var(--border); border-radius: 10px; padding: .75rem .9rem 0; margin: 0 0 .9rem; }
legend { font-weight: 700; font-size: .85rem; padding: 0 .35rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
.form-grid .span2 { grid-column: span 2; }
.form-error { color: var(--danger); font-size: .88rem; min-height: 1.2em; margin: 0 0 .6rem; }

.strength { height: 5px; border-radius: 3px; background: var(--surface-2); margin: -.4rem 0 .8rem; overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; transition: width .2s; }
.strength span[data-score="0"] { width: 10%; background: var(--danger); }
.strength span[data-score="1"] { width: 30%; background: var(--danger); }
.strength span[data-score="2"] { width: 55%; background: var(--warn); }
.strength span[data-score="3"] { width: 80%; background: var(--ok); }
.strength span[data-score="4"] { width: 100%; background: var(--ok); }

/* ---------- Écran de verrouillage ---------- */

.lock-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; background: linear-gradient(160deg, var(--sidebar), var(--bg) 70%); }
.lock-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 18px; padding: 2rem 1.6rem; box-shadow: 0 12px 40px rgba(0, 0, 0, .18); text-align: center; }
.lock-card form { text-align: left; margin-top: 1.25rem; }
.lock-card h1 { margin-top: .5rem; }
.lock-logo { display: inline-flex; padding: .8rem; border-radius: 16px; background: var(--primary-soft); color: var(--primary); }
.lock-logo .ico { width: 32px; height: 32px; }
.info-box { text-align: left; background: var(--primary-soft); border-radius: 10px; padding: .75rem .9rem; font-size: .88rem; margin: 1rem 0 0; }
.lock-card .info-box strong { display: block; margin-bottom: .2rem; }
.modal-body .info-box { margin: 0 0 .5rem; }
.sep { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1rem 0; }
.sep::before, .sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.lock-card .small { margin-top: 1rem; }

/* ---------- Mise en page ---------- */

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1rem;
  background: var(--sidebar); color: var(--sidebar-ink); padding: 1.1rem .8rem;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 .4rem; }
.brand .ico { width: 26px; height: 26px; }
.brand small { display: block; opacity: .75; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 600; }
.nav a:hover { background: rgba(255, 255, 255, .08); }
.nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.side-actions { margin-top: auto; display: grid; gap: .25rem; }
.discret .side-actions [data-action=toggle-discret] { background: rgba(255, 255, 255, .16); }
.topbar { display: none; }

main { padding: 1.75rem 2rem 3rem; max-width: 1280px; width: 100%; outline: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: .2rem; text-decoration: none; font-weight: 600; margin-bottom: .6rem; font-size: .9rem; }
.back .ico { width: 16px; height: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0; }
.card.flush { padding: .25rem 0; }
.count { font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: .05rem .5rem; }
.more { display: inline-block; margin-top: .6rem; font-size: .88rem; font-weight: 600; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 0 1rem; align-items: start; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner .btn { flex: none; }

.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Indicateurs ---------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.kpi strong { display: block; font-size: 1.7rem; line-height: 1.1; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi:hover { border-color: var(--primary); }
.kpi-late strong { color: var(--danger); }
.kpi-wait strong { color: var(--wait); }

.campaigns { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1.5rem; }
.campaign-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; font-weight: 600; margin-bottom: .35rem; }

/* ---------- Barres et badges ---------- */

.bar { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; flex: 1; min-width: 60px; }
.bar span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .3s; }
.bar span[data-w="100"] { background: var(--ok); }
.prog { display: flex; align-items: center; gap: .5rem; }
.prog.big { margin: .5rem 0 1rem; }
.prog.big .bar { height: 10px; }
.pct { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3em; text-align: right; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.st-a_faire { background: var(--surface-2); color: var(--muted); }
.st-en_cours { background: var(--primary-soft); color: var(--primary); }
.st-attente_client { background: var(--wait-soft); color: var(--wait); }
.st-a_valider { background: var(--warn-soft); color: var(--warn); }
.st-termine { background: var(--ok-soft); color: var(--ok); }

.due { font-size: .85rem; font-weight: 600; white-space: nowrap; }
.due.late { color: var(--danger); }
.due.soon { color: var(--warn); }
.late { color: var(--danger); font-weight: 600; }
.prio { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-size: .72rem; font-weight: 800; margin-right: .4rem; vertical-align: 1px; }
.masked { color: var(--muted); font-style: italic; }

/* ---------- Listes de missions ---------- */

.mlist { display: flex; flex-direction: column; }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem .6rem; border-top: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.mlist > .mrow:first-child { border-top: 0; }
.card.flush .mrow { padding: .75rem 1.1rem; border-radius: 0; }
.mrow:hover { background: var(--surface-2); }
.mrow.closed { opacity: .7; }
.mrow-main { min-width: 0; }
.mrow-client { font-size: .8rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.mrow-meta { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; margin-top: .2rem; font-size: .82rem; }
.mrow-side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex: none; width: 150px; }
.mrow-side .prog { width: 100%; }

/* ---------- Dossiers ---------- */

.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; }
.dcard { display: flex; flex-direction: column; gap: .45rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.dcard:hover { border-color: var(--primary); }
.dcard.archived { opacity: .6; }
.dcard-head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.dcard-name { font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; }
.dcard-stats { display: flex; gap: .75rem; font-size: .85rem; flex-wrap: wrap; align-items: center; }
.uptodate { color: var(--ok); font-weight: 600; font-size: .88rem; }

.fields { margin: 0; display: grid; gap: .55rem; }
.field { display: grid; grid-template-columns: 45% 1fr; gap: .5rem; font-size: .9rem; }
.field dt { color: var(--muted); }
.field dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; font-size: .92rem; overflow-wrap: anywhere; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { margin: 0; }
details > summary h2::after { content: "▾"; color: var(--muted); font-size: .9rem; }
details[open] > summary { margin-bottom: .75rem; }

.journal-form { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .75rem; }
.journal-form .btn { flex: none; }
.journal { list-style: none; margin: 0; padding: 0; }
.journal li { position: relative; padding: .55rem 0 .55rem 1rem; border-left: 2px solid var(--border); margin-left: .3rem; }
.journal li::before { content: ""; position: absolute; left: -6px; top: .85rem; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.journal li.auto::before { background: var(--border); }
.journal li.auto .j-text { color: var(--muted); font-size: .88rem; }
.j-date { font-size: .78rem; color: var(--muted); }
.j-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.journal .link-btn { color: var(--muted); font-size: .78rem; }

.clist { display: flex; flex-direction: column; }
.crow { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem .4rem; border-top: 1px solid var(--border); text-decoration: none; color: var(--text); flex-wrap: wrap; }
.crow:first-child { border-top: 0; }
.crow:hover { background: var(--surface-2); }
.crow-name { font-weight: 600; }
.crow-issues { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- Paramètres ---------- */

.tpl-list { list-style: none; margin: 0 0 .9rem; padding: 0; }
.tpl-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.tpl-list li:first-child { border-top: 0; }
.bullets { padding-left: 1.1rem; margin: 0; font-size: .9rem; }
.bullets li { margin-bottom: .5rem; }
.danger-zone { border-color: var(--danger); }

/* ---------- Fenêtres modales ---------- */

dialog {
  width: min(640px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 2rem);
  padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 18, 30, .55); }
#ask { width: min(440px, calc(100vw - 1.5rem)); }
dialog > form, dialog > .sheet { display: flex; flex-direction: column; max-height: calc(100dvh - 2rem); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.1rem 1.2rem .6rem; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .4rem 1.2rem 1rem; overflow-y: auto; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; padding: .8rem 1.2rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

.sheet-top { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: .9rem; align-items: start; }
.sheet-top label { margin: 0; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { border-top: 1px solid var(--border); }
.steps li:first-child { border-top: 0; }
.steps .check { margin: 0; padding: .65rem .2rem; }
.steps input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border); }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%);
  max-width: min(520px, calc(100vw - 2rem));
  background: #1b2430; color: #fff; padding: .7rem 1.1rem; border-radius: 10px;
  font-size: .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  opacity: 0; transition: transform .25s, opacity .25s; z-index: 100; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.error { background: var(--danger); }

/* ---------- Mobile ---------- */

@media (max-width: 1000px) {
  .grid2, .grid-detail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .layout { display: block; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar {
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 10;
    padding: calc(.4rem + env(safe-area-inset-top)) .6rem .4rem 1rem;
    background: var(--sidebar); color: var(--sidebar-ink);
  }
  .topbar .icon-btn:hover { background: rgba(255, 255, 255, .1); }
  .topbar .brand { padding: 0; }
  .topbar .brand .ico { width: 22px; height: 22px; }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 10;
    height: auto; padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, .08);
  }
  .sidebar .brand, .side-actions { display: none; }
  .nav { flex-direction: row; justify-content: space-around; }
  .nav a { flex-direction: column; gap: .15rem; padding: .4rem .3rem; font-size: .7rem; font-weight: 600; flex: 1; text-align: center; }
  .nav a .ico { width: 22px; height: 22px; }
  main { padding: 1rem 1rem 2rem; }
  h1 { font-size: 1.35rem; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: .95rem 1rem; }
  .mrow { flex-direction: column; align-items: stretch; gap: .45rem; }
  .mrow-side { flex-direction: row; align-items: center; width: auto; justify-content: space-between; }
  .mrow-side .prog { width: 55%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span2 { grid-column: auto; }
  .filters select { flex: 1 1 45%; }
  .sheet-top { grid-template-columns: 1fr 1fr; }
  .sheet-top label { grid-column: span 2; }
  .banner { flex-direction: column; align-items: stretch; }
  .journal-form { flex-direction: column; align-items: stretch; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  dialog > form, dialog > .sheet { max-height: 100dvh; height: 100%; }
  .modal-head { padding-top: calc(1rem + env(safe-area-inset-top)); }
  .modal-body { flex: 1; }
  .modal-foot { padding-bottom: calc(.8rem + env(safe-area-inset-bottom)); }
  #ask { height: auto; width: calc(100vw - 1.5rem); margin: auto; border-radius: 16px; }
  #ask > form { height: auto; }
  .modal-foot .spacer { display: none; }
  .modal-foot .btn { flex: 1 1 auto; }
  #toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media print {
  .sidebar, .topbar, .head-actions, .btn { display: none !important; }
  .layout { display: block; }
}

/* ---------- Tableaux (dossiers, suivi mensuel) ---------- */

.head-actions.center { justify-content: center; }
.strong { font-weight: 600; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--muted); font: inherit; font-weight: 600; padding: .45rem .8rem; cursor: pointer; min-height: 38px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary-soft); color: var(--primary); }

.grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dtable, .grille { border-collapse: collapse; width: 100%; font-size: .88rem; }
.dtable th, .grille th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: .6rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.dtable td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dtable tbody tr { cursor: pointer; }
.dtable tbody tr:hover { background: var(--surface-2); }
.dtable tr.archived { opacity: .55; }
.dtable .prog { min-width: 130px; }

.grille th, .grille td { border-bottom: 1px solid var(--border); }
.grille td { text-align: center; padding: 0; height: 34px; min-width: 46px; font-weight: 700; font-size: .78rem; border-left: 1px solid var(--border); }
.grille thead th { text-align: center; }
.grille .g-code, .grille .g-meta { color: var(--muted); font-weight: 500; padding: 0 .5rem; border-left: 0; min-width: 0; }
.grille .g-name { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--surface); padding: .35rem .6rem; max-width: 240px; min-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .85rem; text-transform: none; letter-spacing: 0; color: var(--text); box-shadow: 1px 0 0 var(--border); }
.grille .g-name a { color: inherit; text-decoration: none; }
.grille .g-name a:hover { text-decoration: underline; }
.grille tbody tr:hover td, .grille tbody tr:hover th { background-color: var(--surface-2); }
.grille td[data-action] { cursor: pointer; }
.grille tfoot td, .grille tfoot th { color: var(--muted); font-weight: 600; font-size: .75rem; border-bottom: 0; }
.g-ok, .grille tbody tr:hover td.g-ok { background: var(--ok-soft); color: var(--ok); }
.g-late, .grille tbody tr:hover td.g-late { background: var(--danger-soft); color: var(--danger); }
.g-wait, .grille tbody tr:hover td.g-wait { background: var(--wait-soft); color: var(--wait); }
.g-progress, .grille tbody tr:hover td.g-progress { background: var(--primary-soft); color: var(--primary); }
.g-todo { color: var(--muted); }
.g-none { background: repeating-linear-gradient(135deg, transparent 0 5px, var(--surface-2) 5px 7px); }
.legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .8rem; color: var(--muted); }
.legend span[class^="g-"] { display: inline-block; min-width: 30px; text-align: center; border-radius: 5px; padding: .1rem .3rem; font-weight: 700; margin-left: .4rem; }
.legend .g-todo { background: var(--surface-2); }

/* ---------- Import ---------- */

dialog.wide { width: min(980px, calc(100vw - 1.5rem)); }
.imp-top { margin-top: 1rem; }
.imp-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.imp-col { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .6rem; min-width: 0; }
.imp-col.mapped { border-color: var(--primary); background: var(--primary-soft); }
.imp-head { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-ex { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: .15rem 0 .4rem; min-height: 1.2em; }
.imp-col select { min-height: 36px; padding: .3rem .5rem; font-size: .88rem; }
.imp-summary { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: .75rem .9rem; margin-top: .5rem; }
.imp-summary.warn { background: var(--warn-soft); color: var(--warn); }

@media (max-width: 760px) {
  .nav a span { font-size: .66rem; }
  .imp-cols { grid-template-columns: 1fr 1fr; }
  .grille .g-code, .grille .g-meta, .grille thead th:nth-child(1), .grille thead th:nth-child(3), .grille thead th:nth-child(4) { display: none; }
  .grille .g-name { min-width: 112px; max-width: 128px; font-size: .8rem; }
  .grille td { min-width: 40px; }
  dialog.wide { width: 100vw; }
}

/* ---------- Calendrier fiscal ---------- */

.cal-obs { display: grid; gap: .1rem; margin-bottom: .75rem; }
.cal-ob { padding: .5rem .2rem; border-top: 1px solid var(--border); margin: 0; }
.cal-ob:first-child { border-top: 0; }
.cal-clients { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .75rem; }
.cal-clients summary { cursor: pointer; font-weight: 600; }
.cal-list { max-height: 260px; overflow-y: auto; margin-top: .5rem; }
.cal-list .check { margin: 0; padding: .3rem 0; }

/* ---------- Messages clients ---------- */

.msg-models { margin-bottom: .9rem; flex-wrap: wrap; }
.msg-missions { border: 1px solid var(--border); border-radius: 10px; padding: .4rem .7rem; margin-bottom: .8rem; max-height: 180px; overflow-y: auto; }
.msg-missions .check { margin: 0; padding: .3rem 0; }
#msg-body { font-size: .92rem; line-height: 1.5; }

/* ---------- Aide ---------- */

.help summary { list-style: none; cursor: pointer; }
.help summary::-webkit-details-marker { display: none; }
.help summary h2 { margin: 0; }
.help summary h2::after { content: "▾"; color: var(--muted); font-size: .9rem; margin-left: auto; }
.help[open] summary { margin-bottom: .6rem; }
.help-body { font-size: .95rem; }
.help-body li { margin-bottom: .4rem; }
.help-body ol, .help-body ul { padding-left: 1.2rem; margin: 0; }
.top-actions .icon-btn { color: inherit; }

/* ---------- Graphiques ---------- */

:root { --series-1: #2a78d6; --series-2: #eb6834; --ok-ink: #1e7a4f; }
@media (prefers-color-scheme: dark) { :root { --series-1: #3987e5; --series-2: #d95926; } }

.viz { width: 100%; height: auto; display: block; overflow: visible; }
.viz-grid { stroke: var(--border); stroke-width: 1; }
.viz-base { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.viz-axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.viz-label { fill: var(--text); font-size: 12px; font-weight: 700; font-family: inherit; }
.viz-hit { fill: transparent; cursor: default; outline: none; }
.viz-hit.hover, .viz-hit:focus { fill: var(--text); fill-opacity: .05; }
.viz-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; font-size: .82rem; color: var(--muted); margin: -.2rem 0 .5rem; }
.viz-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.key-box { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.key-line { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.key-series-1 { background: var(--series-1); }
.key-series-2 { background: var(--series-2); }
.key-text { background: var(--text); }
.viz-table { margin-top: .6rem; font-size: .88rem; }
.viz-table summary { cursor: pointer; color: var(--primary); font-weight: 600; }
#viz-tip { position: absolute; display: none; z-index: 200; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .65rem; font-size: .82rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); white-space: nowrap; }
#viz-tip .tip-title { color: var(--muted); font-size: .76rem; margin-bottom: .15rem; }
#viz-tip strong { font-variant-numeric: tabular-nums; }

/* ---------- Analyse FEC ---------- */

.fec-drop { text-align: center; padding: 2.4rem 1rem; border: 2px dashed var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.fec-drop:hover, .fec-drop.over { border-color: var(--primary); background: var(--primary-soft); }
.fec-drop-ico { width: 38px; height: 38px; color: var(--primary); margin-bottom: .4rem; }
.fec-progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: .8rem 0 .4rem; }
.fec-progress span { display: block; height: 100%; width: 0; background: var(--series-1); transition: width .2s; }
.fec-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem 1.2rem; font-size: .9rem; }
.fec-file { overflow-wrap: anywhere; }
.fec-link { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.fec-link label { flex: 1 1 260px; margin: 0; }
.fec-tabs { margin-bottom: 1rem; flex-wrap: wrap; }
.fec-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.fec-kpis .kpi strong { font-size: 1.4rem; }

.lvl { display: inline-flex; align-items: center; gap: .3rem; font-size: .76rem; font-weight: 700; border-radius: 999px; padding: .12rem .55rem .12rem .2rem; white-space: nowrap; }
.lvl b { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; font-size: .7rem; color: #fff; }
.lvl-ok { background: var(--ok-soft); color: var(--ok); } .lvl-ok b { background: var(--ok); }
.lvl-info { background: var(--primary-soft); color: var(--primary); } .lvl-info b { background: var(--primary); font-style: italic; }
.lvl-warn { background: var(--warn-soft); color: var(--warn); } .lvl-warn b { background: var(--warn); }
.lvl-error { background: var(--danger-soft); color: var(--danger); } .lvl-error b { background: var(--danger); }
@media (prefers-color-scheme: dark) { .lvl b { color: #11161d; } }

.fec-checks { list-style: none; margin: 0; padding: 0; }
.fec-check { border-top: 1px solid var(--border); }
.fec-check:first-child { border-top: 0; }
.fec-check-row, .fec-check summary { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem .2rem; }
.fec-check summary { cursor: pointer; list-style: none; }
.fec-check summary::-webkit-details-marker { display: none; }
.fec-check summary::after { content: "▾"; color: var(--muted); margin-left: auto; }
.fec-check .lvl { flex: none; min-width: 108px; }
.fec-check-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.fec-check-text strong { font-weight: 600; }
.fec-ex { margin: 0 0 .6rem; padding: .5rem .8rem .5rem 1.6rem; background: var(--surface-2); border-radius: 8px; font-size: .8rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.fec-ex li { margin: .15rem 0; }

.dtable.num td:not(:first-child):not(:nth-child(2)), .dtable.num th:not(:first-child):not(:nth-child(2)) { text-align: right; font-variant-numeric: tabular-nums; }
.dtable.sig td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.dtable.sig tr.strong td { font-weight: 700; border-top: 1px solid var(--muted); }
.dtable.sig { margin-bottom: 1rem; }
.dtable.balance td:nth-child(2) { white-space: normal; min-width: 180px; }
.dtable td.cred { color: var(--wait); }
.dtable tfoot th { text-align: right; }
.dtable tfoot th:first-child { text-align: left; }

.fec-hist { list-style: none; margin: 0 0 .8rem; padding: 0; }
.fec-hist li { padding: .55rem 0; border-top: 1px solid var(--border); display: grid; gap: .25rem; }
.fec-hist li:first-child { border-top: 0; }

@media (max-width: 1000px) { .fec-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .fec-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fec-check-row, .fec-check summary { flex-wrap: wrap; gap: .35rem .6rem; }
  .fec-check .lvl { min-width: 0; }
  .nav a span { font-size: .6rem; }
}
.viz-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 760px) { .viz-scroll .viz { min-width: 600px; } }

/* ---------- Pièces à demander ---------- */

.pieces-opts { align-items: center; }
.inline-label { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.inline-label input { width: auto; margin: 0; }
.pieces-group { margin-top: .9rem; }
.pieces-group h3 { display: flex; align-items: center; gap: .4rem; margin: 0 0 .3rem; font-size: .9rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.check.piece { margin: 0; padding: .45rem .2rem; border-top: 1px solid var(--border); }
.check.piece input:not(:checked) + span { color: var(--muted); text-decoration: line-through; }
.piece-row { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .6rem; border-top: 1px solid var(--border); }
.piece-row .check.piece { flex: 1 1 320px; border-top: 0; }
.piece-rub { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-left: auto; }
.piece-rub select { width: auto; min-height: 32px; padding: .2rem .5rem; font-size: .85rem; margin: 0; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.pieces-head { display: flex; align-items: center; gap: .4rem; margin: 1.2rem 0 .1rem; font-size: 1rem; }
.piece-row.pending { padding: .45rem .2rem; }
.piece-row.pending .piece-text { flex: 1 1 320px; font-size: .92rem; color: var(--text); }
.piece-rub .btn.small { margin: 0; }
.pieces-ecartes { margin-top: 1rem; }
.pieces-ecartes summary { cursor: pointer; font-weight: 700; font-size: .95rem; }
.pieces-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.banner.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Revue analytique et note de synthèse ---------- */

.revue-load { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; }
.revue-load > span { flex: 1 1 320px; }
.dtable td.up { color: var(--ok); }
.dtable td.down { color: var(--danger); }
.dtable.revue tr.flag td { background: var(--warn-soft); }
.dtable.revue td.comment { min-width: 220px; text-align: left !important; }
.dtable.revue td.comment input { min-height: 32px; padding: .25rem .5rem; font-size: .85rem; }
.inline-label input[type=number] { width: 110px; }
.note-preview { border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem 1.4rem; background: #fff; color: #1b2430; margin-top: .6rem; }
.note { font-size: .92rem; color: #1b2430; }
.note h1 { font-size: 1.4rem; margin: .2rem 0; }
.note h2 { font-size: 1rem; margin: 1.2rem 0 .5rem; border-bottom: 1px solid #c9d2dc; padding-bottom: .2rem; display: block; }
.note-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid #1f3a5f; padding-bottom: .6rem; }
.note-cab { font-weight: 700; color: #1f3a5f; }
.note-sub { color: #52606d; }
.note-date { color: #52606d; font-size: .85rem; }
.note-table { width: 100%; border-collapse: collapse; }
.note-table th, .note-table td { padding: .3rem .4rem; border-bottom: 1px solid #e3e8ee; text-align: right; font-variant-numeric: tabular-nums; }
.note-table th:first-child, .note-table td:first-child { text-align: left; }
.note ul { padding-left: 1.1rem; margin: 0; }
.note li { margin: .25rem 0; }
.note-free { white-space: pre-wrap; }
.note-foot { margin-top: 1.4rem; font-size: .75rem; color: #6b7785; }
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body.printing { background: #fff; }
  .note { font-size: 10.5pt; }
}
.dtable.sig td:first-child { white-space: normal; }
@media (max-width: 760px) { .dtable.sig td { padding: .45rem .4rem; } }
.more-btn { margin-top: .6rem; }

/* ---------- Analyse FEC : espaces Mois / Révision / Consultation ---------- */

.fec-spaces { display: flex; margin-bottom: .75rem; }
.fec-spaces button { flex: 1 1 0; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; text-align: left; padding: .55rem .9rem; min-height: 48px; }
.fec-spaces button strong { font-size: 1rem; color: var(--text); }
.fec-spaces button span { font-size: .76rem; font-weight: 500; line-height: 1.3; }
.fec-spaces button.on { background: var(--primary); color: var(--primary-ink); }
.fec-spaces button.on strong { color: var(--primary-ink); }
.space-card { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.space-card strong { font-size: 1.05rem; }
.space-card em { font-style: normal; font-size: .75rem; font-weight: 700; color: var(--primary); }
.space-card:hover, .space-card.on { border-color: var(--primary); }
.tva-amt { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; padding: .6rem .7rem; margin: .2rem 0 .8rem; background: var(--surface-2); border-radius: 10px; }
.tva-amt-label { font-weight: 700; font-size: .88rem; }
.tva-amt select { width: auto; min-height: 36px; }
.tva-amt-input { display: inline-flex; align-items: center; gap: .3rem; }
.tva-amt-input input { width: 9.5rem; min-height: 36px; text-align: right; }
#grille-pop .tva-amt { margin: .6rem 0 0; }
.tva-chip { font-size: .75rem; font-weight: 700; border-radius: 999px; padding: .05rem .5rem; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tva-chip.pay { background: var(--warn-soft); color: var(--warn); }
.tva-chip.cred { background: var(--ok-soft); color: var(--ok); }
.grille td .g-amt { display: block; font-size: .62rem; font-weight: 600; white-space: nowrap; padding: 0 .2rem; opacity: .9; }
.grille td.g-has-amt { line-height: 1.1; }
/* Mois choisi pour le filtre d'avancement */
.grille thead th.g-sel { color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.grille td.g-sel { box-shadow: inset 2px 0 0 var(--primary), inset -2px 0 0 var(--primary); }
.calc-rates { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: 1rem; }
.calc-rates .seg button { min-width: 64px; font-size: 1rem; }
.calc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem 1rem; }
.calc-field { font-weight: 700; margin: 0; }
.calc-input { display: flex; align-items: center; gap: .4rem; margin-top: .3rem; }
.calc-input input { flex: 1; min-width: 0; font-size: 1.25rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.calc-field.src input { border-color: var(--primary); background: var(--primary-soft); }
.calc-val { background: none; border: 0; padding: .1rem .2rem; font: inherit; color: inherit; cursor: copy; border-radius: 6px; font-variant-numeric: tabular-nums; }
.calc-val:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.calc-val:disabled { cursor: default; color: var(--muted); }
.calc-vent input { width: 9rem; text-align: right; min-height: 34px; }
.calc-all td, .calc-vent td { text-align: right; }
.calc-all td:first-child, .calc-vent td:first-child { text-align: left; font-weight: 700; }
@media (max-width: 760px) {
  .calc-fields { grid-template-columns: minmax(0, 1fr); }
  .calc-vent input { width: 6rem; }
  /* Barre du bas limitée à six entrées : le calcul de TVA est dans la barre du haut. */
  .nav a[data-nav=calcul], .nav a[data-nav=releves] { display: none; }
}
.tva-params select { min-height: 32px; font-size: .82rem; max-width: 100%; }
.tva-params td { vertical-align: top; }
.tva-calc tr.strong td { font-weight: 700; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.badge.beta { background: var(--warn-soft); color: var(--warn); font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; vertical-align: middle; }
.mois-head .fec-kpis { margin-bottom: 0; }
.mois-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.mois-nav .inline-label { margin: 0; }
.mois-nav .btn { min-width: 38px; justify-content: center; font-size: 1.1rem; }
.mois-name { font-size: 1.1rem; margin-left: .3rem; }
.dtable.tp tr.flag td { background: var(--warn-soft); }
.tp-detail { border-top: 1px solid var(--border); padding: .5rem 0; }
.tp-detail summary { cursor: pointer; }
@media (max-width: 1000px) { .grid3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .fec-spaces button { align-items: center; text-align: center; padding: .5rem .4rem; }
  .fec-spaces button span { display: none; }
  .fec-tabs { display: flex; }
  .fec-tabs button { flex: 1 1 auto; }
}

/* Cycles de révision */
.kpi em { display: block; font-style: normal; font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.cycle-tiles { margin-bottom: 0; }
button.kpi { font: inherit; text-align: left; cursor: pointer; width: 100%; }
button.kpi:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.mdots { display: inline-flex; gap: 3px; vertical-align: middle; }
.mdots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--border); background: transparent; }
.mdots i.on { background: var(--series-1); border-color: var(--series-1); }
.dtable.d441 td:first-child, .dtable.cyc-ext td:nth-child(2), .dtable.tiers-cyc td:first-child { text-align: left; }
.dtable.cyc-ext tr.strong td { font-weight: 700; background: var(--bg); }
.dtable.cyc-ext td:nth-last-child(2) { white-space: nowrap; }
.inline-label input[type=number] { width: 4.5rem; }
.dtable.num.d441 td:nth-child(2), .dtable.num.d441 th:nth-child(2), .dtable.num.tiers-cyc td:nth-child(2), .dtable.num.tiers-cyc th:nth-child(2) { text-align: right; }
.dtable.num.l3 td:nth-child(3), .dtable.num.l3 th:nth-child(3), .dtable.num.l4 td:nth-child(4), .dtable.num.l4 th:nth-child(4) { text-align: left; }
.dtable.num.r2 td:nth-child(2), .dtable.num.r2 th:nth-child(2) { text-align: right; }

/* Écritures proposées */
.ecr-prop { border-top: 1px solid var(--border); padding: .8rem 0 .4rem; }
.ecr-prop:first-of-type { border-top: 0; }
.ecr-prop.off { opacity: .55; }
.ecr-prop .check > span { display: flex; flex-direction: column; gap: .15rem; }
.ecr-edit { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin: .45rem 0 .45rem 1.9rem; }
.ecr-edit input[type=number] { width: 8rem; }
.ecr-edit input[type=text], .ecr-opts input[type=text] { width: 7rem; }
.ecr-prop .grid-wrap { margin-left: 1.9rem; }
.dtable.ecr-lines { font-size: .85rem; }
.dtable.ecr-lines td:nth-child(2) { white-space: normal; }
@media (max-width: 640px) { .ecr-edit, .ecr-prop .grid-wrap { margin-left: 0; } }

/* Feuille de travail de révision */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.wp-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: .2rem 0 .6rem; font-size: .88rem; }
.wp-progress { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); }
.wp-track { display: inline-block; width: 120px; height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.wp-track i { display: block; height: 100%; width: 0; background: var(--ok); }
.wp-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .4rem 0 .15rem 116px; }
.wp-row select { width: auto; min-height: 34px; padding: .25rem .5rem; font-size: .85rem; margin: 0; }
.wp-row input[type=text] { flex: 1 1 220px; min-height: 34px; padding: .25rem .6rem; font-size: .85rem; margin: 0; }
.wp-row .link-btn, .fec-ex .link-btn { font-size: .8rem; }
.fec-checks.wp .fec-check.wp-done { opacity: .62; }
.fec-ex li { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.memo-list { list-style: none; padding: 0; margin: 0; }
.memo-list li { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; padding: .55rem 0; border-top: 1px solid var(--border); }
.memo-list li:first-child { border-top: 0; }
.wp-table td:nth-child(2) { text-align: left; }
@media (max-width: 760px) { .wp-row { margin-left: 0; } }
.dtable.num.batch td:nth-child(5), .dtable.num.batch th:nth-child(5) { text-align: left; white-space: nowrap; }

/* Traitement élément par élément */
.wp-count { display: inline-block; margin-left: .4rem; font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; }
.wp-count.ok { color: var(--ok); background: var(--ok-soft); }
.wp-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .2rem 0 .5rem; font-size: .85rem; }
.wp-bulk select { width: auto; min-height: 32px; padding: .2rem .5rem; font-size: .85rem; margin: 0; }
.fec-ex.wp-els { list-style: none; padding: .35rem .6rem; }
.fec-ex.wp-els li.wp-el { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; align-items: center; padding: .3rem 0; border-top: 1px solid var(--border); margin: 0; }
.fec-ex.wp-els li.wp-el:first-child { border-top: 0; }
.wp-el-ctl { display: inline-flex; gap: .4rem; align-items: center; font-family: inherit; font-size: .8rem; }
.wp-el-ctl select { width: auto; min-height: 30px; padding: .15rem .4rem; font-size: .8rem; margin: 0; font-family: system-ui, sans-serif; }
.wp-el-ctl input[type=text] { width: 13rem; min-height: 30px; padding: .15rem .5rem; font-size: .8rem; margin: 0; font-family: system-ui, sans-serif; }
.wp-el.done .wp-el-text { color: var(--muted); text-decoration: line-through; }
.wp-el.wait .wp-el-text { color: var(--wait); }
.note-table tr.wp-sub td { font-size: .85em; color: #52606d; }
@media (max-width: 900px) { .fec-ex.wp-els li.wp-el { grid-template-columns: 1fr; } .wp-el-ctl { flex-wrap: wrap; } .wp-el-ctl input[type=text] { flex: 1 1 10rem; width: auto; } }

/* Suivi mensuel : tri et étapes */
.grille th.g-sort { cursor: pointer; user-select: none; }
.grille th.g-sort:hover, .grille th.g-sort.on { color: var(--primary); }
.grille td.g-progress, .grille td.g-late, .grille td.g-wait { line-height: 1.05; }
.grille td .g-step { display: block; font-size: .7rem; font-weight: 700; padding: 0 .2rem; white-space: nowrap; }
.grille td .g-frac { display: block; font-size: .62rem; font-weight: 600; opacity: .75; }
.grille td { min-width: 58px; }
.legend .g-leg { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; padding: .15rem .35rem; }
.legend .g-leg .g-step { font-size: .68rem; font-weight: 700; }
.legend .g-leg .g-frac { font-size: .6rem; opacity: .75; }
#grille-pop { position: absolute; z-index: 60; width: min(320px, calc(100vw - 16px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: .7rem .75rem; }
#grille-pop .gp-head { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .5rem; }
#grille-pop .gp-steps { list-style: none; margin: 0 0 .3rem; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
#grille-pop .gp-steps button { width: 100%; display: flex; align-items: center; gap: .55rem; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: .4rem .55rem; font: inherit; font-size: .88rem; cursor: pointer; min-height: 36px; }
#grille-pop .gp-steps button span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); font-size: .72rem; font-weight: 700; color: var(--muted); flex: none; }
#grille-pop .gp-steps button.done { background: var(--ok-soft); border-color: transparent; }
#grille-pop .gp-steps button.done span { background: var(--ok); border-color: var(--ok); color: #fff; }
#grille-pop .gp-steps button.current { outline: 2px solid var(--ok); outline-offset: -1px; font-weight: 700; }
#grille-pop .gp-steps button:hover { border-color: var(--primary); }
#grille-pop .gp-foot { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; margin-top: .4rem; }
#grille-pop .gp-req { margin: .4rem 0 0; padding: .4rem .5rem; border-radius: 6px; background: var(--wait-soft); }
@media (prefers-color-scheme: dark) { #grille-pop .gp-steps button.done span { color: #11161d; } }
.legend .g-leg span { display: block; margin-left: 0; min-width: 0; padding: 0; background: none; }
#grille-pop .gp-steps li.gp-par button { border-left: 3px solid var(--primary); }
#grille-pop .gp-head { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: .5rem; }
#grille-pop .gp-head > div { display: flex; flex-direction: column; gap: .1rem; }
#grille-pop .gp-state { font-size: .78rem; font-weight: 700; color: var(--primary); }
#grille-pop .gp-state.ok { color: var(--ok); }
#grille-pop .gp-close { flex: none; width: 32px; height: 32px; }

/* Demandes directes aux fournisseurs */
.supp-list { display: flex; flex-direction: column; }
.supp-row { display: grid; grid-template-columns: minmax(0, 1.4fr) auto auto auto; gap: .5rem .9rem; align-items: center; padding: .65rem 0; border-top: 1px solid var(--border); }
.supp-row:first-child { border-top: 0; }
.supp-row input { width: 11rem; min-height: 34px; padding: .25rem .5rem; font-size: .88rem; margin: 0; }
.supp-actions { display: inline-flex; gap: .4rem; }
@media (max-width: 900px) { .supp-row { grid-template-columns: 1fr; } .supp-row input { width: 100%; } .supp-row .inline-label { display: flex; } }
/* Contrôle de la TVA */
.dtable.tva-draft tr.tva-h td { background: var(--surface-2); font-weight: 600; font-size: .85rem; }
.dtable.tva-draft tr.strong td, .dtable.tva-conc tr.strong td { font-weight: 700; }
.dtable.tva-draft tr.flag td, .dtable.tva-conc tr.flag td { background: var(--warn-soft); }
.dtable.tva-draft td:nth-child(2) { white-space: normal; min-width: 14rem; }
.tva-validate { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; }
.tva-decl .inline-label input[type=number] { width: 8.5rem; }
.dtable.tva-conc .link-btn { white-space: nowrap; }
.tva-validate .lvl { white-space: normal; }
.dtable.tva-acc td:nth-child(2) { white-space: normal; min-width: 10rem; }

/* Anonymisation d'un FEC */
.anon-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 .25rem; max-height: 320px; overflow-y: auto; }
.anon-chip { font: inherit; font-size: .8rem; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.anon-chip span { color: var(--muted); font-size: .72rem; margin-left: .2rem; }
.anon-chip:hover { border-color: var(--primary); }
.anon-chip.pending { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); text-decoration: line-through; }
.anon-chip.user { background: var(--primary-soft); border-color: var(--primary); }
.anon-extra { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin-top: .75rem; }
.anon-extra label { flex: 1 1 260px; }
.anon-preview td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.anon-preview tbody tr { cursor: default; }
.anon-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .5rem 1rem; margin: .25rem 0 .75rem; }
.anon-modes .check input { width: 18px; height: 18px; }
/* Relevés PDF → Excel */
.rel-controls { list-style: none; padding: 0; margin: .4rem 0; font-size: .9rem; }
.rel-controls li { padding: .1rem 0; }
.rel-head { display: inline-flex; align-items: center; gap: .5rem; }
/* Comparer deux FEC */
.cmp-slots { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .75rem; align-items: stretch; margin-bottom: 1rem; }
.cmp-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; padding: 1.4rem 1rem; margin: 0; min-width: 0; }
.cmp-slot.on { border-style: solid; }
.cmp-role { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); }
.cmp-file { overflow-wrap: anywhere; }
.cmp-swap { align-self: center; font-size: 1.2rem; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.cmp-period { flex-wrap: wrap; }
.cmp-entry { border-top: 1px solid var(--border); padding: .45rem 0; }
.cmp-entry summary { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; cursor: pointer; font-size: .9rem; }
.cmp-entry[open] summary { margin-bottom: .4rem; }
.cmp-when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmp-lib { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.cmp-amt { margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmp-table td.n, .cmp-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.cmp-table tbody tr { cursor: default; }
.cmp-table td { white-space: normal; }
.cmp-table td.n { white-space: nowrap; }
.cmp-table tr.cmp-rub td { background: var(--surface-2); font-weight: 700; font-size: .8rem; }
.cmp-table tr.cmp-strong td { font-weight: 700; }
.cmp-table tr.cmp-diff td:last-child { color: var(--wait); }
@media (max-width: 760px) { .cmp-slots { grid-template-columns: 1fr; } .cmp-swap { justify-self: center; } }
.rel-table td:nth-child(2) { white-space: normal; min-width: 260px; }
.rel-table tbody tr { cursor: default; }

/* ---------- Notes ---------- */

.note-group { margin-bottom: 1.4rem; }
.note-group h2 .link-btn { font-size: .82rem; font-weight: 400; }
.ncard { display: flex; flex-direction: column; gap: .45rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--text); box-shadow: var(--shadow); cursor: pointer; min-width: 0; }
.ncard:hover, .ncard:focus-visible { border-color: var(--primary); }
.ncard-title { font-size: 1.02rem; overflow-wrap: anywhere; }
.ncard-meta { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; font-size: .82rem; }
.ncard-client { font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .02em; font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ncard-text { font-size: .88rem; color: var(--muted); white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.badge.pin { background: var(--primary-soft); color: var(--primary); }
.note-text { margin-bottom: 1rem; padding: .8rem .9rem; background: var(--surface-2); border-radius: 10px; }
@media (max-width: 760px) {
  /* Barre du bas limitée à six entrées : les notes sont dans la barre du haut. */
  .nav a[data-nav=notes] { display: none; }
}
.step-edit ol { list-style: none; margin: 0 0 .6rem; padding: 0; counter-reset: etape; display: grid; gap: .45rem; }
.step-row { display: flex; align-items: center; gap: .3rem; counter-increment: etape; }
.step-row::before { content: counter(etape); flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .8rem; display: inline-flex; align-items: center; justify-content: center; }
.step-row input { flex: 1; min-width: 0; }
.step-row .icon-btn { width: 32px; height: 32px; flex: none; font-size: .95rem; color: var(--muted); }
.step-row .icon-btn:hover { color: var(--text); }
.step-row:first-child [data-dir="-1"], .step-row:last-child [data-dir="1"] { visibility: hidden; }
.step-edit > .btn { margin-bottom: .4rem; }
