/* ============================================================
   CRM — Feuille de style
   Mise en page : bandeau gauche fixe + grand tableau central à en-têtes collants.
   Registre comptable : papier froid, encre verte, cases d'état codées par couleur.
   ============================================================ */
:root {
  --bg: #f2f4f9;          /* fond papier froid */
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #131b2d;
  --ink-2: #47536b;
  --ink-3: #78839a;
  --line: #dce1eb;
  --line-2: #c6cedc;
  --accent: #1c3b78;      /* bleu marine */
  --accent-2: #2c58ad;
  --accent-soft: #e3eaf7;
  --side: #0d1b38;
  --side-ink: #d5dff1;
  --side-dim: #8da2c6;
  --ok: #dff3e5; --ok-ink: #17643a;
  --late: #fbe1df; --late-ink: #a3241b;
  --warn: #fcefd5; --warn-ink: #8a5a06;
  --na: #ece6f3; --na-ink: #7a6a8f;     /* non applicable : violet grisé */
  --sel: #fff7d6;
  --shadow: 0 12px 32px rgba(13, 27, 56, .16);
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b111e; --surface: #121a2b; --surface-2: #172136; --ink: #e2e8f4; --ink-2: #a6b2c9; --ink-3: #7a879e;
    --line: #222c42; --line-2: #2e3a55; --accent: #7ea8f2; --accent-2: #a1c0f6; --accent-soft: #19284a;
    --side: #070d19; --side-ink: #ccd7ec; --side-dim: #7d90b5;
    --ok: #173826; --ok-ink: #8fe0ac; --late: #43201d; --late-ink: #ffaaa2; --warn: #3d3016; --warn-ink: #f3c770;
    --na: #2a2433; --na-ink: #b6a6cc; --sel: #3a3519; --shadow: 0 12px 32px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b111e; --surface: #121a2b; --surface-2: #172136; --ink: #e2e8f4; --ink-2: #a6b2c9; --ink-3: #7a879e;
  --line: #222c42; --line-2: #2e3a55; --accent: #7ea8f2; --accent-2: #a1c0f6; --accent-soft: #19284a;
  --side: #070d19; --side-ink: #ccd7ec; --side-dim: #7d90b5;
  --ok: #173826; --ok-ink: #8fe0ac; --late: #43201d; --late-ink: #ffaaa2; --warn: #3d3016; --warn-ink: #f3c770;
  --na: #2a2433; --na-ink: #b6a6cc; --sel: #3a3519; --shadow: 0 12px 32px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13px/1.45 var(--f-body); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.sm { font-size: 12px; }
.ic { width: 16px; height: 16px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--accent); background: var(--accent); color: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.danger { background: var(--surface); color: var(--late-ink); border-color: var(--late-ink); }
.btn.danger:hover { background: var(--late); }
.btn.wide { width: 100%; justify-content: center; height: 38px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.icon-only { width: 32px; padding: 0; justify-content: center; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.x { border: 0; background: none; font-size: 18px; line-height: 1; color: var(--ink-3); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.x:hover { background: var(--late); color: var(--late-ink); }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100%; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.brand b { display: block; font-family: var(--f-display); font-size: 15px; letter-spacing: .04em; }
.brand small { color: var(--side-dim); font-size: 11px; }
.mark { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; background: var(--side-ink); color: var(--side); font: 800 18px var(--f-display); }
#nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--side-ink); text-decoration: none; font-weight: 500; }
#nav a:hover { background: rgba(255, 255, 255, .07); }
#nav a.on { background: var(--side-ink); color: var(--side); font-weight: 700; }
#nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-h { display: flex; align-items: center; justify-content: space-between; margin: 16px 10px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--side-dim); }
.nav-add { border: 1px solid var(--side-dim); background: none; color: var(--side-ink); border-radius: 5px; width: 22px; height: 22px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.nav-add .ic { width: 13px; height: 13px; }
.nav-empty { margin: 0 10px; color: var(--side-dim); font-size: 12px; }
.side-foot { padding: 10px 8px 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sync { width: 100%; display: flex; gap: 10px; align-items: center; background: none; border: 0; color: var(--side-ink); text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.sync:hover { background: rgba(255, 255, 255, .07); }
.sync small { display: block; color: var(--side-dim); font-size: 11px; }
.sync.bad small { color: #ffb4ab; }
.sync.spin .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 20px 10px; }
.top h1 { margin: 0; font: 700 22px/1.2 var(--f-display); letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; text-wrap: balance; }
.legend { margin: 4px 0 0; color: var(--ink-2); max-width: 900px; font-size: 12.5px; }
.legend:empty { display: none; }
.me { display: flex; align-items: center; gap: 10px; flex: none; }
.who { text-align: right; }
.who b { display: block; }
.who small { color: var(--ink-3); }
.demo-badge { background: var(--warn); color: var(--warn-ink); font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: 4px; }
#asuser { height: 32px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: 0 8px; max-width: 220px; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 20px 16px; }
.view-in { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-in > div { min-height: 0; }

/* ---------- Barre d'outils ---------- */
.grid-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 8px 0 10px; }
.tb-left, .tb-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.year { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-2); }
.year select { height: 32px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: 0 8px; font-weight: 700; color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; height: 30px; padding: 0 12px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--accent); color: var(--surface); font-weight: 600; }
.count { color: var(--ink-3); }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--sel); border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px 10px; margin-bottom: 8px; }

/* ---------- Tableau ---------- */
.grid-scroll { flex: 1; min-height: 240px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; vertical-align: middle; background: var(--surface); }
.grid thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--ink-2); font-size: 11.5px; }
.grid thead tr.counters th { top: 0; z-index: 4; height: 24px; border-bottom-color: var(--line); }
.grid thead tr.counters + tr th { top: 24px; }
.grid .th { display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; padding: 6px 4px 6px 8px; min-height: 38px; }
.grid .lbl small { display: block; font-weight: 500; color: var(--ink-3); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.fbtn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 4px; width: 20px; height: 20px; font-size: 10px; line-height: 1; cursor: pointer; color: var(--ink-3); flex: none; padding: 0; }
.fbtn:hover { border-color: var(--accent); color: var(--accent); }
.fbtn.on, .fbtn.sorted { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.ctr { display: block; padding: 3px 8px; font-size: 11px; font-weight: 500; color: var(--late-ink); white-space: nowrap; }
.ctr b { font-size: 12.5px; }
.ctr.done { color: var(--ok-ink); }
.grid .sel { width: 34px; text-align: center; }
.grid .sel input { margin: 0; cursor: pointer; }
.sticky0 { position: sticky; left: 0; z-index: 2; }
.sticky1 { position: sticky; left: 34px; z-index: 2; box-shadow: 1px 0 0 var(--line-2); }
.grid thead .sticky0, .grid thead .sticky1 { z-index: 5; }
.grid tbody tr:hover td { background: var(--surface-2); }
.grid tbody tr.selected td { background: var(--sel); }
.grid td.num, .grid th.num { text-align: right; }
.cellwrap { position: relative; display: flex; align-items: center; min-height: 32px; padding: 0 8px; gap: 2px; }
.grid td.wrap .cellwrap { white-space: normal; max-width: 340px; padding: 4px 8px; }
.grid td .cellwrap { white-space: nowrap; }
.cell-in { width: 140px; min-width: 0; border: 1px solid transparent; background: transparent; height: 28px; padding: 0 4px; border-radius: 4px; }
.cell-in:hover { border-color: var(--line-2); }
.cell-in:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.cell-in.num { width: 82px; text-align: right; font-family: var(--f-mono); font-size: 12.5px; }
.cell-in.num::placeholder { color: var(--ink-3); font-style: italic; opacity: .9; }
input[type=date].cell-in { width: 122px; font-size: 12px; }
select.cell-in { padding: 0 2px; width: auto; max-width: 180px; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.st-ok { background: var(--ok) !important; }
.st-ok .cell-in { color: var(--ok-ink); font-weight: 600; }
.st-late { background: var(--late) !important; }
.st-late .cell-in::placeholder { color: var(--late-ink); }
.st-na { background: var(--na) !important; }
/* case confirmée par Pennylane (déclaration envoyée / acceptée) */
td.pl .cellwrap { position: relative; }
td.pl .cellwrap::after { content: "PL"; position: absolute; right: 2px; top: 1px; font: 700 8px/1 var(--f-body); letter-spacing: .04em; color: var(--ok-ink); opacity: .75; pointer-events: none; }
td.st-late.pl .cellwrap::after { content: "REJET"; color: var(--late-ink); }
.na { color: var(--na-ink); font-size: 11px; font-style: italic; }
.cbtn, .ibtn { flex: none; border: 0; background: none; cursor: pointer; color: var(--ink-3); opacity: .35; padding: 2px; border-radius: 3px; display: grid; place-items: center; }
td:hover .cbtn, td:hover .ibtn, .cbtn.has { opacity: 1; }
.cbtn.has { color: var(--warn-ink); }
.cbtn .ic { width: 13px; height: 13px; }
.ibtn { width: 16px; height: 16px; font: italic 700 11px Georgia, serif; border: 1px solid currentColor; border-radius: 50%; padding: 0; }
.cbtn:hover, .ibtn:hover { color: var(--accent); opacity: 1; }
.namecell { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 6px 4px 10px; min-width: 220px; }
.nm { display: flex; flex-direction: column; min-width: 0; }
.n1 { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.n2 { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); }
.pen { flex: none; border: 1px solid transparent; background: none; border-radius: 5px; width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; color: var(--ink-3); }
.pen:hover { border-color: var(--line-2); color: var(--accent); background: var(--accent-soft); }
td.empty { padding: 40px; text-align: center; color: var(--ink-3); }
.pl-link { display: inline-flex; gap: 4px; align-items: center; text-decoration: none; font-weight: 600; }
.pl-link .ic { width: 13px; height: 13px; }
.tl { display: flex; align-items: center; gap: 8px; width: 100%; }
.tl-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 60px; }
.tl-bar span { display: block; height: 100%; background: var(--ink-3); }
.tl.ok .tl-bar span { background: var(--ok-ink); } .tl.warn .tl-bar span { background: var(--warn-ink); } .tl.late .tl-bar span { background: var(--late-ink); }
.tl-l { font-size: 11.5px; font-weight: 600; white-space: nowrap; min-width: 96px; }
.tl.ok .tl-l { color: var(--ok-ink); } .tl.warn .tl-l { color: var(--warn-ink); } .tl.late .tl-l { color: var(--late-ink); }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.p-BROUILLON { background: var(--warn); color: var(--warn-ink); } .p-EMISE { background: var(--accent-soft); color: var(--accent); } .p-PAYEE { background: var(--ok); color: var(--ok-ink); }
.acts { display: flex; gap: 4px; }
.acts .ic { width: 13px; height: 13px; }

/* ---------- Popovers ---------- */
.popover { position: fixed; z-index: 1000; background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; min-width: 200px; max-width: 340px; }
.pop-title { font-weight: 700; margin: 2px 4px 6px; }
pre.calc { margin: 0 4px 4px; white-space: pre-wrap; font: 12px/1.6 var(--f-mono); color: var(--ink); }
.flt { width: 260px; }
.fl-sort { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.fl-sort:hover { background: var(--accent-soft); }
.flt hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.fl-search { width: 100%; height: 30px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 8px; background: var(--surface); }
.fl-list { max-height: 240px; overflow: auto; margin: 6px 0; border: 1px solid var(--line); border-radius: 4px; padding: 4px; }
.fl-list label { display: flex; align-items: center; gap: 6px; padding: 3px 4px; cursor: pointer; border-radius: 3px; }
.fl-list label:hover { background: var(--surface-2); }
.fl-list label span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-list label em { font-style: normal; color: var(--ink-3); font-size: 11px; }
.fl-list .all { font-weight: 600; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.fl-actions { display: flex; justify-content: flex-end; gap: 6px; }
.cols-pop { max-height: 60vh; overflow: auto; }
.cols-pop label { display: flex; gap: 8px; padding: 3px 4px; cursor: pointer; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.menu button:hover { background: var(--accent-soft); }

/* ---------- Modales et formulaires ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 900; background: rgba(8, 15, 32, .45); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(820px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font: 700 16px var(--f-display); text-wrap: balance; }
.modal-b { padding: 16px 18px; overflow: auto; }
.modal-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-f .danger { margin-right: auto; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; color: var(--ink-2); font-size: 12px; }
.form label.chk { flex-direction: row; font-weight: 500; color: var(--ink); font-size: 13px; }
.form input:not([type=checkbox]):not([type=file]), .form select, .form textarea { height: 34px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 10px; background: var(--surface); font-weight: 400; color: var(--ink); font-size: 13px; }
.form textarea { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.form textarea.mono { font: 12.5px/1.6 var(--f-mono); }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
.form h4 { margin: 8px 0 0; font: 700 13px var(--f-display); color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inl { display: flex; align-items: center; gap: 6px; }
.inl input { flex: 1; min-width: 0; }
.hint { margin: 0; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.err { color: var(--late-ink); margin: 0; min-height: 1em; }
.tabs, .subtabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button, .subtabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs button.on, .subtabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.subtabs { margin-bottom: 4px; }
.ech { background: var(--accent-soft); border-radius: var(--r); padding: 10px 14px; }
.ech ul { margin: 6px 0 0; padding-left: 18px; }
.fac-cat { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 10px; }
.fac-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.fac-h h4 { margin: 0; }
.fac-l { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 140px 28px; gap: 6px; align-items: center; margin-bottom: 6px; }
.fac-l select, .fac-l input { height: 30px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 6px; background: var(--surface); }
.fac-l input { width: 90px; text-align: right; }
.fac-tot { text-align: right; margin: 4px 0 0; }
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { text-align: left; font-size: 11px; color: var(--ink-3); font-weight: 600; padding: 4px; border-bottom: 1px solid var(--line); }
table.lines td { padding: 4px; border-bottom: 1px solid var(--line); }
table.lines input, table.lines select { width: 100%; height: 30px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 6px; background: var(--surface); }
table.lines input.n { width: 90px; text-align: right; }
table.lines td.num { text-align: right; white-space: nowrap; }
.inv-tot { display: flex; justify-content: flex-end; gap: 18px; padding-top: 6px; }
.prog { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.prog span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.vcat { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.vcat fieldset { border: 1px solid var(--line); border-radius: var(--r); margin: 0; padding: 8px 10px; }
.vcat legend { font-weight: 700; padding: 0 4px; color: var(--ink); }
.vcat label { flex-direction: row; font-weight: 400; color: var(--ink); align-items: center; gap: 6px; }

/* ---------- Paramétrage ---------- */
.settings { overflow: auto; padding-top: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; max-width: 860px; }
.presta { display: flex; flex-direction: column; gap: 12px; }
.presta .card { padding: 12px 14px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-row img { height: 48px; border: 1px solid var(--line); border-radius: 4px; padding: 4px; background: #fff; }
.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
code { font-family: var(--f-mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; }

/* ---------- Connexion ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); background: var(--side); }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font: 700 20px var(--f-display); }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; color: var(--ink-2); }
.login-card input { height: 38px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 10px; background: var(--surface); }
.brand.big { padding: 0 0 6px; }
.brand.big b { color: var(--ink); font-size: 18px; }
.brand.big small { color: var(--ink-3); }
.brand.big .mark { background: var(--accent); color: var(--surface); }

/* ---------- Notifications ---------- */
#toasts { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; transition: opacity .3s, transform .3s; }
.toast.err { background: var(--late-ink); color: var(--surface); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Téléphone ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .side { flex-direction: row; align-items: center; overflow-x: auto; padding-left: max(8px, env(safe-area-inset-left, 0px)); }
  .brand { padding: 10px 8px; } .brand div { display: none; }
  #nav { display: flex; gap: 2px; overflow: visible; padding: 6px 4px; flex: none; }
  #nav a span { display: none; } #nav a { padding: 8px; }
  .nav-h, .nav-empty { display: none; }
  .side-foot { border: 0; padding: 0 8px; } .sync span { display: none; }
  .top { padding: 12px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); flex-wrap: wrap; }
  .view { padding: 0 max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); }
  .row2 { grid-template-columns: 1fr; }
  .fac-l { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
#root { height: 100%; }

/* ============================================================
   TÂCHES
   ============================================================ */
:root { --av1: #2c58ad; --av2: #8a5a06; --av3: #5b4a8b; --av4: #a3412b; --av5: #2f5e8f; --av6: #5f6b2b; --ai: #f0f4ff; --ai-ink: #3346a8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --av1: #7ea8f2; --av2: #d9a441; --av3: #a493da; --av4: #e08a74; --av5: #79a9dc; --av6: #a9b864; --ai: #1c2238; --ai-ink: #a9b7ff; } }
:root[data-theme="dark"] { --av1: #7ea8f2; --av2: #d9a441; --av3: #a493da; --av4: #e08a74; --av5: #79a9dc; --av6: #a9b864; --ai: #1c2238; --ai-ink: #a9b7ff; }
.badge { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; background: var(--side-dim); color: var(--side); }
.badge.late { background: #ff8a7d; color: #3a0d08; }
#nav a.on .badge { background: var(--side); color: var(--side-ink); }
.ai-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--ai); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 8px 8px 14px; margin: 4px 0 6px; }
.ai-spark { color: var(--ai-ink); font-size: 18px; }
.ai-bar input { flex: 1; min-width: 220px; height: 36px; border: 0; background: transparent; font-size: 14px; color: var(--ink); }
.ai-bar input:focus { outline: none; }
.ai-bar:focus-within { border-color: var(--ai-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn.loading { opacity: .7; cursor: progress; }
.tsel, .tsearch { height: 32px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); padding: 0 8px; }
.tsearch { width: 240px; }
.av { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--surface); flex: none; letter-spacing: .02em; }
.av.big { width: 32px; height: 32px; font-size: 12px; }
.av1 { background: var(--av1); } .av2 { background: var(--av2); } .av3 { background: var(--av3); } .av4 { background: var(--av4); } .av5 { background: var(--av5); } .av6 { background: var(--av6); }
.av.none { background: var(--line-2); color: var(--ink-2); }
.load { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.load-c { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; text-align: left; min-width: 170px; }
.load-c:hover, .load-c.on { border-color: var(--accent); }
.load-c.on { background: var(--accent-soft); }
.load-t { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.load-t small { color: var(--ink-3); font-size: 11px; }
.load-t em { color: var(--late-ink); font-style: normal; font-weight: 600; }
.load-bar { position: relative; height: 4px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.load-bar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }
.load-bar .lt { background: var(--late-ink); }
.sugs { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.sugs summary { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; font-weight: 600; list-style: none; }
.sugs summary::-webkit-details-marker { display: none; }
.sugs summary::before { content: "▸"; color: var(--ink-3); transition: transform .15s; }
.sugs[open] summary::before { transform: rotate(90deg); }
.sugs summary .btn { margin-left: auto; }
.sug-n { background: var(--warn); color: var(--warn-ink); border-radius: 10px; padding: 0 7px; font-size: 12px; }
.sug-list { max-height: 260px; overflow: auto; border-top: 1px solid var(--line); }
.sug { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.sug:last-child { border-bottom: 0; }
.sug-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sug-main span { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prio { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.prio.p-URGENTE { background: var(--late); color: var(--late-ink); }
.prio.p-HAUTE { background: var(--warn); color: var(--warn-ink); }
.prio.p-NORMALE { background: var(--accent-soft); color: var(--accent); }
.prio.p-BASSE { background: var(--surface-2); color: var(--ink-3); }
.due { font-size: 11.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.due.late { color: var(--late-ink); } .due.today { color: var(--warn-ink); } .due.soon { color: var(--accent); }
.tbody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board { flex: 1; min-height: 300px; display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; }
.col header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font: 700 13px var(--f-display); }
.col header .n { margin-left: auto; color: var(--ink-3); font: 600 12px var(--f-body); }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.s-A_FAIRE { background: var(--ink-3); } .s-EN_COURS { background: var(--accent); } .s-ATTENTE_CLIENT { background: var(--warn-ink); } .s-TERMINEE { background: var(--ok-ink); }
.col-body { flex: 1; overflow-y: auto; padding: 0 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; border-radius: 0 0 10px 10px; transition: background .12s; }
.col-body.over { background: var(--accent-soft); }
.col-empty { color: var(--ink-3); font-size: 12px; text-align: center; padding: 18px 8px; border: 1px dashed var(--line-2); border-radius: 8px; margin: 0; }
.col-empty.big { padding: 40px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 10px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .12s, transform .12s; }
.tcard:hover { box-shadow: 0 4px 14px rgba(13, 27, 56, .1); }
.tcard.dragging { opacity: .45; transform: rotate(1deg); }
.tcard.done h4 { text-decoration: line-through; color: var(--ink-3); }
.tcard h4 { margin: 0; font-size: 13.5px; line-height: 1.35; font-weight: 650; }
.tc-top { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.tc-cat { font-size: 11px; color: var(--ink-3); }
.tc-rec { color: var(--accent); font-weight: 700; }
.tc-check { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface); cursor: pointer; display: grid; place-items: center; color: var(--surface); font-size: 12px; font-weight: 700; padding: 0; flex: none; }
.tc-check:hover { border-color: var(--ok-ink); background: var(--ok); color: var(--ok-ink); }
.tcard.done .tc-check, .tc-check.on { background: var(--ok-ink); border-color: var(--ok-ink); color: var(--surface); }
.tc-client { margin: 0; font-size: 12px; color: var(--accent); font-weight: 600; }
.tc-foot { display: flex; align-items: center; gap: 8px; }
.tc-foot .av { margin-left: auto; }
.tc-ck, .tc-cm { font-size: 11px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 3px; }
.tc-cm .ic { width: 12px; height: 12px; }
.tc-prog { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.tc-prog span { display: block; height: 100%; background: var(--ok-ink); }
.tlist tbody tr { cursor: pointer; }
.tlist th { padding: 8px; text-align: left; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.ck-h { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; color: var(--ink); }
.ckl { display: flex; flex-direction: column; gap: 2px; }
.form label.ck { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: 13px; padding: 4px 6px; border-radius: 4px; }
.form label.ck:hover { background: var(--surface-2); }
.form label.ck input { width: 16px; height: 16px; accent-color: var(--ok-ink); }
.form label.ck span { flex: 1; }
.form label.ck.on span { text-decoration: line-through; color: var(--ink-3); }
.ck-add { display: flex; gap: 8px; align-items: flex-start; }
.ck-add input, .ck-add textarea { flex: 1; }
.cml { display: flex; flex-direction: column; gap: 10px; }
.cm { display: flex; gap: 10px; }
.cm small { color: var(--ink-3); }
.cm p { margin: 2px 0 0; white-space: pre-wrap; }
.ai-prev { display: flex; flex-direction: column; gap: 12px; }
.aip { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.aip-t { font-weight: 650; height: 34px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 0 10px; background: var(--surface); }
.aip-row { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1fr; gap: 6px; }
.aip-row select, .aip-row input { height: 32px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 6px; background: var(--surface); min-width: 0; }
.aip-ck { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 12.5px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 3000; overflow: hidden; }
.confetti i { position: absolute; top: 55%; width: 8px; height: 12px; border-radius: 2px; animation: conf 1.3s cubic-bezier(.2, .7, .3, 1) forwards; }
.confetti .c0 { background: var(--accent); } .confetti .c1 { background: var(--warn-ink); } .confetti .c2 { background: var(--av3); } .confetti .c3 { background: var(--late-ink); }
@keyframes conf { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), -380px) rotate(var(--r)); opacity: 0; } }
@media (max-width: 860px) {
  .board { grid-template-columns: repeat(4, minmax(230px, 82vw)); }
  .row3, .aip-row { grid-template-columns: 1fr; }
  .tsearch { width: 100%; }
}

/* ---------- Juridique annuel ---------- */
.modal.jurm { width: min(980px, 100%); }
.jur h4.jur-h { margin: 14px 0 2px; font: 700 13px var(--f-display); color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.jur h4.jur-h small { font: 400 12px var(--f-body); color: var(--ink-3); }
.jur-src { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); }
.ok-pill { background: var(--ok); color: var(--ok-ink); font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 10px; }
.jur-box { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2); display: grid; gap: 6px; }
.jur-box p { margin: 0; font-size: 13px; }
.jur-box.ok { background: var(--ok); color: var(--ok-ink); border-color: transparent; }
.jur-box.warn { background: var(--warn); color: var(--warn-ink); border-color: transparent; }
.jur-box ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.warnline { margin: 0; padding: 7px 10px; border-radius: var(--r); background: var(--late); color: var(--late-ink); font-size: 12.5px; }
.jur-calc { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.jur-calc > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.jur-calc > div:last-child { border-bottom: 0; }
.jur-calc small { color: var(--ink-3); }
.jur-calc .tot { background: var(--accent-soft); font-weight: 700; }
.jur-calc b { font-variant-numeric: tabular-nums; }
.jur-calc .btns, .jur .btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
.jur-row { display: grid; grid-template-columns: 2fr 1fr auto 1.6fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.jur-row.conv { grid-template-columns: 3fr 1.5fr 1fr auto; }
.jur-ai { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.jur-docs { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.jur-docs li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.jur-docs li:last-child { border-bottom: 0; }
.jur-next { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 10px; border-top: 1px dashed var(--line-2); }
.jur-next b { font-size: 12px; color: var(--ink-3); margin-right: 4px; }
.jur-btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 12px; padding: 2px 10px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--accent); white-space: nowrap; }
.jur-btn:hover { background: var(--accent-soft); }
.jur-btn.ok { background: var(--ok); color: var(--ok-ink); border-color: transparent; }
.jur-btn.warn { background: var(--warn); color: var(--warn-ink); border-color: transparent; }

.cp-ok { color: var(--ok-ink); font-size: 12px; white-space: nowrap; }
.cp-btn { border: 0; border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; background: var(--late); color: var(--late-ink); }
.cp-btn.s-PROPOSEE, .cp-btn.s-ACCEPTEE { background: var(--warn); color: var(--warn-ink); }
.cp-btn.s-REALISEE { background: var(--ok); color: var(--ok-ink); }
.cp-btn.s-REFUSEE { background: var(--na); color: var(--na-ink); }
.cpline { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }

/* Lettres de mission */
.ldm table.lines input[type=checkbox], .ldm-rep input[type=checkbox] { width: auto; height: auto; }
.ldm-rep td.c { text-align: center; width: 64px; }
.ldm-rep tr.sec td { background: var(--accent-soft); }
.ldm-rep select { width: 70px; }
.ldm-mis td:first-child { width: 28px; }
.ldm-autre { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.ldm-set textarea { width: 100%; }
.ldm-set table.lines textarea { min-width: 260px; font: inherit; font-size: 12px; border: 1px solid var(--line-2); border-radius: 4px; padding: 4px; }
.ldm-prev { display: block; width: 140px; border: 1px solid var(--line); margin: 6px 0; }
@media (max-width: 760px) { .row3 { grid-template-columns: 1fr; } }
