/* ==========================================================================
   EMS Gestion — feuille de style
   Charte EMS Electronics : rouge EMS sur noir, police Inter. Thème clair disponible.
   ========================================================================== */

@font-face { font-family: "Inter EMS"; src: url("../fonts/Inter-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter EMS"; src: url("../fonts/Inter-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #0b0c0e;
  --panel: #141619;
  --panel-2: #1b1e23;
  --panel-3: #22262c;
  --ink: #f2f4f6;
  --muted: #a0a7b0;
  --faint: #757d87;
  --line: #24272d;
  --line-strong: #373c44;
  --brand: #f60000;
  --brand-text: #ff4a4a;
  --brand-soft: rgba(246, 0, 0, .16);
  --ok: #2fbf8f; --ok-soft: rgba(47, 191, 143, .15);
  --warn: #e8942e; --warn-soft: rgba(232, 148, 46, .15);
  --bad: #ff5a52; --bad-soft: rgba(255, 90, 82, .15);
  --info: #5598e7; --info-soft: rgba(85, 152, 231, .15);
  --series-1: #3987e5;
  --series-2: #d95926;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .38);
  --radius: 12px;
  --radius-s: 8px;
  color-scheme: dark;
}

body[data-theme="light"] {
  --bg: #f2f3f5;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --panel-3: #eef0f3;
  --ink: #101216;
  --muted: #5b6370;
  --faint: #868d98;
  --line: #e2e5ea;
  --line-strong: #c8cdd6;
  --brand: #e00000;
  --brand-text: #c40000;
  --brand-soft: #fdeceb;
  --ok: #0e7c63; --ok-soft: #e4f5f0;
  --warn: #a85b10; --warn-soft: #fdf0e3;
  --bad: #c42222; --bad-soft: #fdecea;
  --info: #1c5cab; --info-soft: #e6f0fc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --shadow: 0 1px 2px rgba(16, 18, 22, .06), 0 8px 24px rgba(16, 18, 22, .07);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Inter EMS", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-text); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* --- Écrans d'accueil (connexion, dossier) --------------------------------- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.gate-card.wide { width: min(640px, 100%); }
.gate-logo { width: 240px; max-width: 80%; height: auto; display: block; margin: 0 auto 18px; }
.gate-title { font-size: 20px; font-weight: 700; text-align: center; margin: 0 0 6px; }
.gate-sub { color: var(--muted); text-align: center; margin: 0 0 22px; }
.gate-card .field { margin-bottom: 14px; }
.gate-card .btn { width: 100%; justify-content: center; }
.gate-foot { margin-top: 16px; text-align: center; color: var(--faint); font-size: 12px; }

/* --- Coque -------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brandbar { padding: 16px 18px 10px; }
.brandbar img { width: 100%; max-width: 190px; height: auto; display: block; }
.side-app { padding: 0 18px 10px; font-weight: 700; font-size: 13px; letter-spacing: .02em; color: var(--muted); }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: none; border-radius: var(--radius-s); cursor: pointer; color: var(--muted); text-align: left; }
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--ink); }
.nav-item.active svg { color: var(--brand-text); }
.nav-item .badge { margin-left: auto; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.me-name { font-weight: 700; font-size: 13px; }
.me-role { color: var(--faint); font-size: 12px; }
.sync { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.off { background: var(--warn); }
.side-actions { display: flex; gap: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 28px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.content { flex: 1; overflow: auto; padding: 20px 28px 40px; }
.offline-banner { background: var(--warn-soft); color: var(--warn); padding: 8px 28px; font-size: 13px; border-bottom: 1px solid var(--line); }
.topbar > div:first-child { min-width: 0; }

/* Fenêtre étroite (volet Aircall ouvert à côté, petit écran) : en-tête sur deux lignes, menu réduit aux icônes */
@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; padding: 12px 18px 10px; }
  .topbar-actions { margin-left: 0; justify-content: flex-start; width: 100%; }
  .content { padding: 16px 18px 32px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 64px 1fr; }
  .brandbar { padding: 12px 8px 6px; }
  .side-app, .nav-section, .nav-item > span:not(.badge), .me > div:last-child, .sync span, .side-clock .day { display: none; }
  .side-clock { padding: 0 4px 10px !important; text-align: center; }
  .side-clock .time { font-size: 15px !important; }
  .nav { padding: 4px 8px 12px; }
  .nav-item { justify-content: center; padding: 9px 0; position: relative; }
  .nav-item .badge { position: absolute; top: 2px; right: 2px; margin: 0; }
  .side-foot { padding: 10px 6px; align-items: center; }
  .side-actions { flex-direction: column; align-items: center; }
  .side-foot .sync { font-size: 0; justify-content: center; }
}

/* --- Boutons, champs --------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--panel-2); padding: 7px 14px; border-radius: var(--radius-s); cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--panel-2); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint, .hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  padding: 8px 10px; outline: none; min-height: 36px;
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); border-bottom: 1px solid var(--line); padding: 10px 0 4px; }
.checks { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 16px; }

/* --- Cartes, KPI ------------------------------------------------------------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin: -2px 0 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-head .sub { color: var(--faint); font-size: 12px; min-width: 0; }
.card-head .right { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: center; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { color: var(--faint); font-size: 12px; margin-top: 2px; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--line-strong); }

/* --- Badges ------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-text); }
.badge.count { background: var(--brand); color: #fff; padding: 1px 7px; }

/* --- Barre d'outils de liste ---------------------------------------------------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-width: 150px; }
.toolbar .search { min-width: 260px; flex: 0 1 320px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; }
.seg button { border: 0; background: var(--panel-2); padding: 7px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--brand-soft); color: var(--ink); }
.count-note { color: var(--faint); font-size: 12px; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--brand-soft); border: 1px solid var(--brand); border-radius: var(--radius-s); padding: 8px 12px; margin-bottom: 12px; position: sticky; top: -20px; z-index: 5; }
.bulkbar .spacer { flex: 1; }
.filter-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.filter-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; flex-wrap: wrap; }
.filter-row .input { min-height: 32px; padding: 5px 8px; width: auto; }
.chip-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-strong); cursor: pointer; }
.chip-check.on { background: var(--brand-soft); border-color: var(--brand); }
.chip-check input { width: 13px; height: 13px; accent-color: var(--brand); }
.filter-chips { gap: 6px; margin-bottom: 10px; }
.sync-opts { margin-top: 12px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); }
.filter-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: var(--brand-soft); color: var(--ink); border-radius: 999px; padding: 2px 4px 2px 10px; }
.chip .icon-btn { padding: 2px; }
.chip svg { width: 13px; height: 13px; }
.toast { display: flex; align-items: center; }

/* --- Tableau ------------------------------------------------------------------- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); cursor: pointer; white-space: nowrap; user-select: none; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--panel-2); }
.tbl tr.group td { background: var(--panel-2); font-weight: 700; font-size: 12px; color: var(--muted); padding: 7px 12px; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); }
.tbl .strong { font-weight: 700; }
.tbl .muted { color: var(--faint); }
.tbl td.wrap { white-space: normal; }
.tbl td .sub { color: var(--faint); font-size: 12px; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; font-size: 15px; }

/* --- Kanban ------------------------------------------------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kcol { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kcol.over { border-color: var(--brand); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; font-weight: 700; font-size: 13px; }
.kcol-head .badge { margin-left: auto; }
.kcol-body { overflow-y: auto; padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 11px; cursor: pointer; font-size: 13px; }
.kcard:hover { border-color: var(--line-strong); }
.kcard .t { font-weight: 700; }
.kcard .m { color: var(--faint); font-size: 12px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.kcard .tags { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }

/* --- Fiche détaillée ----------------------------------------------------------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.props { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.props dt { color: var(--faint); }
.props dd { margin: 0; overflow-wrap: anywhere; }
.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl-item { display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.tl-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--panel-3); display: grid; place-items: center; color: var(--muted); }
.tl-icon.call { background: var(--info-soft); color: var(--info); }
.tl-icon.ai { background: var(--brand-soft); color: var(--brand-text); }
.tl-head { font-size: 12px; color: var(--faint); }
.tl-body { white-space: pre-wrap; font-size: 13px; margin-top: 2px; }
.ai-box { background: var(--panel-2); border-left: 3px solid var(--brand); border-radius: 6px; padding: 8px 10px; margin-top: 6px; white-space: pre-wrap; font-size: 13px; }
.steps { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.step { flex: 1; min-width: 90px; text-align: center; padding: 7px 6px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--faint); border-radius: 6px; cursor: pointer; border: 1px solid var(--line); }
.step.done { background: var(--brand-soft); color: var(--ink); }
.step.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.step.lost { background: var(--bad-soft); color: var(--bad); }

/* --- Planning ------------------------------------------------------------------ */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal-h { background: var(--panel); padding: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-d { background: var(--panel); min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-d.out { background: var(--panel-2); }
.cal-d.out .cal-n { color: var(--faint); }
.cal-d.today .cal-n { background: var(--brand); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-n { font-size: 12px; font-weight: 700; }
.cal-ev { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--info-soft); color: var(--ink); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--series-1); }
.cal-ev.full { border-left-color: var(--ok); }
.cal-ev.cancel { opacity: .5; text-decoration: line-through; }
.fill { height: 6px; background: var(--panel-3); border-radius: 6px; overflow: hidden; min-width: 60px; }
.fill > i { display: block; height: 100%; background: var(--series-1); border-radius: 6px; }

/* --- Graphiques ---------------------------------------------------------------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis text { fill: var(--faint); font-size: 11px; stroke: none; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--line-strong); stroke-width: 1; }
.chart .bar1 { fill: var(--series-1); stroke: none; }
.chart .bar2 { fill: var(--series-2); stroke: none; }
.chart .line1 { stroke: var(--ink); stroke-width: 2; fill: none; }
.chart .hit { fill: transparent; stroke: none; cursor: default; }
.chart .hit:hover { fill: var(--panel-3); opacity: .5; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 90; pointer-events: none; background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--shadow); border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 140px; }
.tip b { display: block; margin-bottom: 4px; }
.tip .row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.tip .row span:last-child { color: var(--ink); font-weight: 600; }

/* --- Messagerie ---------------------------------------------------------------- */
.chat { display: grid; grid-template-columns: 250px 1fr; height: calc(100vh - 150px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-side { border-right: 1px solid var(--line); overflow-y: auto; padding: 10px; }
.chat-side h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 12px 6px 6px; display: flex; align-items: center; }
.chat-side h4 .icon-btn { margin-left: auto; padding: 2px; }
.chan { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); text-align: left; }
.chan:hover { background: var(--panel-2); color: var(--ink); }
.chan.on { background: var(--brand-soft); color: var(--ink); }
.chan .badge { margin-left: auto; }
.chat-main { display: flex; flex-direction: column; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; align-items: center; gap: 10px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: grid; grid-template-columns: 32px 1fr; gap: 10px; }
.msg-head { font-size: 12px; color: var(--faint); }
.msg-head b { color: var(--ink); margin-right: 6px; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-src { font-size: 11px; }
.chat-input { border-top: 1px solid var(--line); padding: 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 40px; max-height: 160px; }
.day-sep { text-align: center; font-size: 11px; color: var(--faint); margin: 4px 0; }

/* --- Modales, toasts ------------------------------------------------------------ */
.modal-host { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 50; padding: 24px; }
.modal { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); width: min(760px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; }
.modal.small { width: min(460px, 100%); }
.modal.large { width: min(1100px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--panel); border: 1px solid var(--line-strong); border-left: 4px solid var(--ok); box-shadow: var(--shadow); border-radius: 8px; padding: 10px 14px; max-width: 420px; font-size: 13px; }
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }

.note { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; color: var(--muted); font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.note.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.note + .note, .note + .card, .card + .note { margin-top: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; }
.secret { font-family: Consolas, monospace; letter-spacing: .05em; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.files { display: flex; flex-direction: column; gap: 4px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: var(--panel-3); padding: 3px 8px; border-radius: 6px; cursor: pointer; }
.perm { font-size: 12px; }
.perm td, .perm th { padding: 6px 8px !important; text-align: center !important; }
.perm td:first-child, .perm th:first-child { text-align: left !important; min-width: 220px; }

/* pointage */
.pt-clock { font-size: 44px; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pt-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pt-actions .btn { flex: 1; justify-content: center; min-height: 44px; font-size: 15px; }
.pt-sum { display: flex; gap: 22px; margin: 12px 0 4px; font-size: 14px; }
.pt-frise { margin-top: 8px; min-width: 160px; }
.pt-line { position: relative; height: 12px; border-radius: 6px; background: var(--panel-3); overflow: hidden; }
.pt-seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.pt-seg.work { background: var(--ok); }
.pt-seg.pause { background: var(--warn); }
.pt-seg.live { opacity: .65; }
.pt-ticks { position: relative; height: 14px; font-size: 10px; color: var(--faint); }
.pt-ticks span { position: absolute; top: 1px; transform: translateX(-50%); }
.pt-week td { vertical-align: middle; }
.pt-week td:last-child { min-width: 220px; }
.pt-week .badge { margin: 0 4px 4px 0; }
.tbl tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.pt-now { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.pt-person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); }
.pt-person > div:nth-child(2) { flex: 1; min-width: 0; }
.pt-mobile-only { width: 100%; text-align: center; }
/* comptes bancaires */
.bank-total { background: var(--brand-soft); border-radius: var(--radius-s); padding: 14px 16px; }
.bank-amount { font-size: 28px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* écran de pointage : QR code renouvelé toutes les 30 s */
/* --- Éditeur de modèles (type Word) -------------------------------------------- */
.rte { border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; background: var(--panel-2); }
.rte-tb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.rte-btn { border: 1px solid transparent; background: none; color: var(--ink); min-width: 30px; height: 28px; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 13px; }
.rte-btn:hover { background: var(--panel-2); border-color: var(--line-strong); }
.rte-btn:disabled { opacity: .35; cursor: default; }
.rte-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.rte-page { background: #fff; color: #111; padding: 26px 30px; min-height: 560px; max-height: 70vh; overflow: auto; font-family: "Segoe UI", Arial, sans-serif; font-size: 10.5pt; line-height: 1.45; outline: none; margin: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.rte-page:focus { box-shadow: 0 0 0 2px var(--brand); }
.rte-src { border: 0; border-radius: 0; min-height: 560px; }

/* --- Lecteur Aircall ------------------------------------------------------------ */
.ems-player { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; padding: 8px 12px; box-shadow: var(--shadow); width: min(720px, calc(100% - 40px)); }
.ems-player > svg { width: 20px; height: 20px; color: var(--brand-text); flex: none; }
.ems-player .strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.al-team table td, .al-team table th { padding: 6px 8px; vertical-align: middle; }
.al-team .table-wrap { max-height: 360px; overflow: auto; }

/* --- Photo d'une pièce (webcam), rapprochement bancaire ------------------------ */
.cam-video { display: block; width: 100%; max-height: 62vh; background: #000; border-radius: var(--radius-s); object-fit: contain; }
.rap-row { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); margin-bottom: 6px; gap: 10px; }
.rap-row .badge { flex: none; }

/* --- Devis et factures --------------------------------------------------------- */
.fac-lines td { vertical-align: top; padding: 6px 6px; }
.fac-lines td:first-child { min-width: 260px; }
.fac-lines .input { min-height: 30px; padding: 4px 6px; font-size: 13px; }
.fac-tot { text-align: right; font-size: 13px; line-height: 1.7; min-width: 220px; }

/* --- Parcours Qualiopi -------------------------------------------------------- */
.qp-matrix th { text-align: center; font-size: 11px; white-space: normal; max-width: 90px; }
.qp-matrix th:first-child { text-align: left; }
.qp-cell { text-align: center; cursor: pointer; }
.qp-cell:hover { background: var(--panel-2); }
.qp-dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--panel-3); color: var(--muted); font-weight: 700; font-size: 13px; }
.qp-dot.ok { background: var(--ok-soft); color: var(--ok); }
.qp-dot.info { background: var(--info-soft); color: var(--info); }
.qp-dot.warn { background: var(--warn-soft); color: var(--warn); }
.qp-dot.bad { background: var(--bad-soft); color: var(--bad); }
.qp-step { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.qp-step:last-child { border-bottom: 0; }
.qp-step .row .btn { margin: 2px 0; }
.qp-timeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 6px 18px; }
.qp-tl { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; }
.qp-tl.na { opacity: .45; }
.qp-tl-date { color: var(--faint); font-size: 12px; min-width: 52px; }

/* --- Ressources humaines ------------------------------------------------------- */
.rh-alerts { display: flex; flex-direction: column; gap: 6px; }
.rh-alert { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); font-size: 13px; cursor: pointer; flex-wrap: wrap; }
.rh-alert:hover { border-color: var(--line-strong); }
.rh-alert > span:nth-child(2) { flex: 1; min-width: 200px; }
.rh-contrat { padding: 12px 0; border-top: 1px solid var(--line); }
.rh-contrat:first-of-type { border-top: 0; }
.rh-cal th.rh-day, .rh-cal td.rh-cell { padding: 4px 2px; text-align: center; font-size: 10.5px; min-width: 22px; }
.rh-cal th.rh-day.we, .rh-cal td.rh-cell.we, .rh-cal th.rh-day.fer, .rh-cal td.rh-cell.fer { background: var(--panel-3); color: var(--faint); }
.rh-cal th.rh-day.today { color: var(--brand-text); font-weight: 800; }
.rh-cal td.rh-cell { cursor: pointer; height: 30px; position: relative; }
.rh-cal td.rh-cell.abs { background: color-mix(in srgb, var(--abs) 28%, transparent); color: var(--ink); font-weight: 700; }
.rh-cal td.rh-cell.abs.am { background: linear-gradient(90deg, color-mix(in srgb, var(--abs) 28%, transparent) 50%, transparent 50%); }
.rh-cal td.rh-cell.abs.pm { background: linear-gradient(90deg, transparent 50%, color-mix(in srgb, var(--abs) 28%, transparent) 50%); }
.rh-cal td.rh-cell.abs.pend { background-image: repeating-linear-gradient(45deg, transparent 0 4px, color-mix(in srgb, var(--abs) 45%, transparent) 4px 8px); }
.rh-bul { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.rh-bul-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); cursor: pointer; font-size: 13px; }
.rh-bul-item svg { width: 16px; height: 16px; color: var(--faint); }
.rh-bul-item.ok svg { color: var(--ok); }
.rh-bul-item > span:nth-child(2) { flex: 1; }

.pt-screen { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.pt-screen-qr { width: min(62vh, 520px); aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 14px; }
.pt-screen-qr svg { width: 100%; height: 100%; display: block; }
.pt-screen-clock { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-screen-bar { width: min(62vh, 520px); height: 6px; border-radius: 6px; background: var(--panel-3); overflow: hidden; }
.pt-screen-bar i { display: block; height: 100%; background: var(--brand); transition: width .5s linear; }
.modal:fullscreen { width: 100%; max-height: none; border-radius: 0; justify-content: center; }
.modal:fullscreen .pt-screen-qr, .modal:fullscreen .pt-screen-bar { width: min(78vh, 900px); }

@media (max-width: 1200px) {
  .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail { grid-template-columns: 1fr; }
}
/* --- Aircall : appels en cours ------------------------------------------------- */
.al-live { display: flex; flex-direction: column; gap: 8px; }
.al-call { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); flex-wrap: wrap; }
.al-call .avatar { flex: none; }
.al-call .al-who { flex: 1 1 220px; min-width: 0; }
.al-call .al-who .strong, .al-call .al-who .faint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-call .al-acts { display: flex; gap: 6px; align-items: center; margin-left: auto; flex: none; }
.card-head .right.al-head { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }

/* --- Encaissements (section ajoutée par l'agent encaissements) --------------------- */
.grid.g4:has(> .enc-kpi) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.enc-fac { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px; margin: -2px -6px; border: 0; border-radius: var(--radius-s); background: transparent; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
.enc-fac:hover { background: var(--brand-soft); }
.enc-hors { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.enc-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.enc-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.enc-tot { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; font-size: 13px; min-width: 0; }
.enc-amount { font-size: 18px; }
@media (max-width: 1200px) { .grid.g4:has(> .enc-kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- Charges : blocs, crédits & leasing (section ajoutée par l'agent charges) ------ */
/* Onglets [Charges | Crédits & leasing] dans l'en-tête, carte « Par bloc » et bascule « Chiffres : sélection | tout » */
.charges-tabs { margin-right: 6px; }
.charges-top { margin-bottom: 16px; padding: 14px 16px; }
.charges-top .card-head { margin-bottom: 10px; flex-wrap: wrap; row-gap: 6px; }
.charges-top .card-head .right.charges-kpi-mode { font-size: 12px; color: var(--muted); gap: 8px; }
.charges-bloc-tbl th { cursor: default; }
.charges-bloc-tbl th, .charges-bloc-tbl td { padding: 6px 10px; font-size: 13px; }
.charges-bloc-tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.charges-bloc-tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line-strong); }
/* Fenêtre « Blocs… » : un bloc = une ligne avec ordre (▲ ▼), nom, catégories cochables */
.bloc-list { display: flex; flex-direction: column; gap: 8px; }
.bloc-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel-2); }
.bloc-order { display: flex; flex-direction: column; gap: 0; flex: none; }
.bloc-order .icon-btn { padding: 2px 6px; font-size: 11px; line-height: 1.2; }
.bloc-order .icon-btn:disabled { opacity: .3; cursor: default; }
.bloc-body { flex: 1 1 auto; min-width: 0; }
.bloc-head { flex-wrap: nowrap; }
.bloc-head .bloc-name { flex: 1 1 200px; min-width: 120px; }
.bloc-rest { font-size: 12px; white-space: nowrap; }
.bloc-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.bloc-cats .chip-check { max-width: 100%; }
.bloc-cats .chip-check .faint { font-size: 11px; }
/* Crédits & leasing : progression des échéances, fenêtre détail d'un contrat */
.cr-prog { display: flex; flex-direction: column; gap: 4px; min-width: 90px; }
.cr-prog .fill { width: 90px; }
.cr-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.cr-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.cr-tot { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; font-size: 13px; min-width: 0; }
.cr-amount { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-detail .form-section { margin-top: 14px; }
.cr-ech { margin-top: 10px; }
.cr-ech .tbl td { white-space: nowrap; }
.cr-ech .tbl td:last-child { white-space: normal; }
@media (max-width: 900px) { .cr-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- Filtres : favoris (section ajoutée par l'agent filtres) ----------------------- */
/* Rangée de vues favorites sous la barre d'outils d'une liste (ligne pleine largeur du .toolbar) */
.fav-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 100%; min-width: 0; margin-top: -2px; }
.fav-chips-label { font-size: 12px; font-weight: 700; color: var(--brand-text); margin-right: 2px; line-height: 1; }
.fav-chip { display: inline-block; vertical-align: middle; font-size: 12px; font-weight: 600; line-height: 1.3; padding: 4px 11px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--muted); cursor: pointer; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-chip:hover { color: var(--ink); border-color: var(--faint); }
.fav-chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--ink); }
.fav-chip.fav-chip-add { background: none; border-style: dashed; }
.fav-chip.fav-chip-add:hover { color: var(--brand-text); border-color: var(--brand); }

/* --- Comptabilité : écritures (section ajoutée par l'agent compta-ecritures) ------- */
.ecr-grid { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.ecr-row { display: grid; grid-template-columns: 150px minmax(160px, 2fr) 120px 120px minmax(130px, 1fr) 34px; gap: 8px; align-items: start; }
.ecr-row.head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px; }
.ecr-row .input { min-height: 32px; padding: 5px 8px; width: 100%; }
.ecr-row .input.num { text-align: right; font-variant-numeric: tabular-nums; }
.ecr-row .icon-btn { margin-top: 2px; }
.ecr-hint { font-size: 11px; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ecr-foot { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-s); font-size: 13px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.ecr-foot.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.ecr-foot.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.ecr-foot .spacer { flex: 1; }
@media (max-width: 900px) {
  .ecr-row { grid-template-columns: 1fr 1fr; }
  .ecr-row.head { display: none; }
}

/* --- Comptabilité : états et liasse (section ajoutée par l'agent compta-etats) ----- */
/* Tableaux d'états (compte de résultat, bilan, SIG) : en-têtes, sous-lignes par compte, totaux, colonne variation */
.etat-body > .card + .card, .etat-body > .note + .card, .etat-body > .count-note + .card { margin-top: 16px; }
.etat-body > .note + .note { margin-top: 12px; }
.etat-table th { cursor: default; }
.etat-table th.etat-code, .etat-table td.etat-code { width: 56px; color: var(--faint); font-size: 12px; white-space: nowrap; }
.etat-table td.etat-label { white-space: normal; max-width: none; min-width: 240px; }
.etat-table td.etat-label .sub { font-weight: 400; }
.etat-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.etat-table tr.etat-head td { background: var(--panel-2); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 7px 12px; }
.etat-table tr.etat-sub td { color: var(--faint); font-size: 12px; padding-top: 4px; padding-bottom: 4px; }
.etat-table tr.etat-sub td.etat-label { padding-left: 30px; }
.etat-table tr.etat-total td { font-weight: 700; background: var(--panel-2); border-top: 1px solid var(--line-strong); }
.etat-table tr.etat-grand td { font-weight: 800; background: var(--brand-soft); border-top: 2px solid var(--brand); }
.etat-table td.adj > span { font-weight: 700; text-decoration: underline dotted; text-underline-offset: 3px; }
.etat-table .etat-reset { padding: 0 4px; margin-left: 4px; font-size: 15px; line-height: 1; vertical-align: middle; color: var(--brand-text); }
/* Formulaires de liasse : numéro de ligne, libellé, valeur calculée ou saisie (mode Ajuster) */
.liasse-form td.etat-code span { display: inline-block; min-width: 36px; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: 4px; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); background: var(--panel); }
.etat-table td.etat-edit { padding-top: 4px; padding-bottom: 4px; }
.etat-table .etat-inp { width: 136px; min-height: 28px; padding: 3px 8px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.etat-table td.etat-edit.adj .etat-inp { font-weight: 700; border-color: var(--brand); }
.etat-mention { margin-top: 12px; }
.etat-docs { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 1200px) { .etat-table td.etat-label { min-width: 160px; } .etat-table .etat-inp { width: 110px; } }

/* --- Prévisionnel IA (section ajoutée par l'agent previsionnel) -------------------- */
/* Onglet « Prévisionnel IA » de la comptabilité : données transmises, formulaire, rapport */
.prev .table-wrap { max-height: 440px; }
/* Indicateur d'attente pendant la rédaction par l'assistant (une génération dure plusieurs minutes) */
.prev-wait { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; margin-top: 14px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--panel-2); }
.prev-spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--brand); animation: spin .9s linear infinite; }
.prev-wait-text { min-width: 0; }
.prev-wait-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.prev-wait-sub { font-size: 12px; margin-top: 2px; }
.prev-wait-acts { display: flex; gap: 8px; }
.prev-wait-bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.prev-wait-bar i { display: block; height: 100%; width: 3%; background: var(--brand); border-radius: 999px; transition: width .6s ease; }
/* Éditeur du rapport (page blanche type Word) */
.prev-editor { margin-top: 4px; }
.prev-editor .rte-page { max-height: 75vh; }
/* Typographie du rapport à l'écran (aperçu, fenêtres) ; le PDF embarque sa propre feuille de style */
.prev-report { line-height: 1.5; }
.prev-report h1 { font-size: 20px; margin: 14px 0 6px; }
.prev-report h2 { font-size: 16px; margin: 20px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--brand-text); }
.prev-report h3 { font-size: 14px; margin: 14px 0 4px; }
.prev-report h4 { font-size: 13px; margin: 10px 0 3px; }
.prev-report p { margin: 6px 0; }
.prev-report ul, .prev-report ol { margin: 4px 0 8px; padding-left: 22px; }
.prev-report li { margin: 2px 0; }
.prev-report table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; }
.prev-report th, .prev-report td { border: 1px solid var(--line-strong); padding: 5px 8px; vertical-align: top; }
.prev-report th { background: var(--panel-2); text-align: left; font-weight: 700; }
.prev-report td.num, .prev-report th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.prev-report td.center, .prev-report th.center { text-align: center; }
.prev-report table.wide { font-size: 11px; }
.prev-report table.wide th, .prev-report table.wide td { padding: 3px 4px; }
.prev-report blockquote { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--brand); background: var(--brand-soft); }
.prev-report code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; background: var(--panel-3); padding: 0 4px; border-radius: 4px; }
.prev-report pre { background: var(--panel-3); padding: 8px 10px; border-radius: var(--radius-s); white-space: pre-wrap; font-size: 12px; }
.prev-report hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.prev-report .meta { color: var(--faint); font-size: 12px; margin-bottom: 10px; }
@media (max-width: 900px) { .prev-wait { grid-template-columns: auto minmax(0, 1fr); } .prev-wait-acts { grid-column: 1 / -1; } }

/* --- Tableau de bord personnalisable -------------------------------------------- */
.tdb-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; grid-auto-flow: row dense; }
.tdb-w { min-width: 0; position: relative; }
.tdb-body > .card, .tdb-body > .kpi { margin: 0; }
.tdb-grid.editing .tdb-w { outline: 1px dashed var(--line-strong); outline-offset: 4px; border-radius: var(--radius); cursor: grab; }
.tdb-grid.editing .tdb-body { pointer-events: none; opacity: .85; }
.tdb-grid.editing .tdb-w.dragging { opacity: .4; }
.tdb-w.drop-before { box-shadow: -6px 0 0 -2px var(--brand); }
.tdb-w.drop-after { box-shadow: 6px 0 0 -2px var(--brand); }
.tdb-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-bottom: 6px; padding: 4px 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); font-size: 12px; }
.tdb-handle { cursor: grab; color: var(--faint); font-size: 14px; line-height: 1; }
.tdb-name { flex: 1 1 60px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-weight: 600; }
.tdb-tools { display: flex; align-items: center; gap: 2px; flex: none; margin-left: auto; }
.tdb-tools .icon-btn { padding: 3px 5px; font-size: 11px; }
.tdb-tools .icon-btn:disabled { opacity: .3; cursor: default; }
.tdb-sizes { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; margin: 0 2px; }
.tdb-sizes button { border: 0; background: none; color: var(--muted); padding: 2px 6px; cursor: pointer; font-size: 11px; font-weight: 700; }
.tdb-sizes button + button { border-left: 1px solid var(--line-strong); }
.tdb-sizes button.on { background: var(--brand); color: #fff; }
.tdb-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
/* écrans étroits : 2 colonnes ; un élément ½ ou plus prend toute la ligne */
@media (max-width: 1100px) {
  .tdb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tdb-w.s2, .tdb-w.s3, .tdb-w.s4 { grid-column: span 2 !important; }
}

/* --- Blocs et regroupements (charges, encaissements), charges isolées ------------ */
/* Carte « Soldes par bloc » : regroupements (sous-total), blocs indentés, TOTAL GLOBAL */
.soldes-tbl tr.soldes-grp td { background: var(--panel-2); border-top: 1px solid var(--line-strong); }
.soldes-tbl tr.soldes-in td:first-child { padding-left: 26px; }
.soldes-tbl tr.soldes-in td:first-child .soldes-name::before { content: '↳ '; color: var(--muted); }
.soldes-tbl tr.soldes-off td { color: var(--muted); }
.soldes-tbl tr.soldes-off td.num { text-decoration: line-through; text-decoration-color: var(--line-strong); }
.soldes-tbl tr.soldes-sep td { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 12px; cursor: default; }
.soldes-tbl .soldes-hors { font-size: 11px; }
.soldes-tbl th.soldes-chk, .soldes-tbl td.soldes-chk { width: 56px; text-align: center; }
.soldes-tbl td.soldes-chk input { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; }
.soldes-tbl tfoot tr.soldes-total td { font-size: 14px; }
.soldes-tbl tfoot tr.soldes-note td { font-weight: 400; font-size: 12px; color: var(--muted); border-top: 0; }
/* Fenêtre « Blocs… » : outils par bloc (solde global, regrouper, séparer), section Regroupements */
.bloc-section { margin: 16px 0 8px; font-size: 14px; }
.bloc-section:first-of-type { margin-top: 4px; }
.bloc-tools { flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.bloc-tools .bloc-global { font-size: 12px; }
.bloc-tools .bloc-merge { width: auto; min-width: 150px; max-width: 240px; padding-top: 4px; padding-bottom: 4px; font-size: 12px; }
.bloc-row.bloc-off { opacity: .8; }
.bloc-row.bloc-off .bloc-name { text-decoration: line-through; text-decoration-color: var(--line-strong); }
.bloc-empty { font-size: 12px; padding: 4px 2px; }
/* Fenêtres « Isoler… » / « Réintégrer… » : liste de charges cochables filtrable */
.iso-tools { gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.iso-tools .search { flex: 1 1 220px; min-width: 0; }
.iso-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; padding: 4px 2px; border: 1px solid var(--line); border-radius: var(--radius-s); }
.iso-list .iso-item { padding: 4px 8px; border-radius: 6px; align-items: baseline; }
.iso-list .iso-item:hover { background: var(--panel-2); }

/* --- Bandeau « nouvelle version disponible » ------------------------------------ */
.maj-bandeau { position: fixed; right: 18px; bottom: 18px; z-index: 70; display: flex; align-items: center; gap: 12px; max-width: min(520px, calc(100% - 36px)); padding: 12px 14px; background: var(--panel); border: 1px solid var(--line-strong); border-left: 3px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); }
.maj-bandeau > svg { width: 20px; height: 20px; color: var(--brand-text); flex: none; }

/* --- Kbis / RIB : informations reconnues ---------------------------------------- */
.sd-row { gap: 8px; margin-bottom: 6px; flex-wrap: nowrap; }
.sd-lab { flex: 0 0 180px; color: var(--muted); font-size: 12px; font-weight: 600; }
.sd-row .input { flex: 1; min-width: 0; }
@media (max-width: 700px) { .sd-row { flex-wrap: wrap; } .sd-lab { flex: 1 1 100%; } }

/* --- Applications mobiles (QR codes) -------------------------------------------- */
.app-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.app-qr { background: #fff; padding: 8px; border-radius: var(--radius-s); flex: none; line-height: 0; }
.app-qr svg { width: 132px; height: 132px; display: block; }
.app-info { flex: 1 1 220px; min-width: 0; }
.app-url { font-weight: 700; word-break: break-all; }
.app-steps { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

@media print {
  .side, .topbar-actions, .toolbar { display: none !important; }
  .shell { display: block; }
  .content { overflow: visible; }
}

/* ---------- messagerie : émojis, aperçus d'images, wizz ---------- */
.emoji-wrap { position: relative; display: inline-flex; }
.emoji-panel {
  position: absolute; bottom: 110%; left: 0; z-index: 60; width: 320px; max-height: 300px; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.emoji-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 6px 0 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-grid button { font-size: 20px; line-height: 1; background: none; border: 0; border-radius: 8px; padding: 5px; cursor: pointer; }
.emoji-grid button:hover { background: var(--panel-3); }
.chat-img { max-width: 260px; max-height: 220px; border-radius: 10px; margin-top: 6px; display: block; cursor: pointer; border: 1px solid var(--line); }
.msg-wizz { font-weight: 600; color: var(--brand-text); display: flex; align-items: center; gap: 6px; }
@keyframes wizz-shake {
  0%, 100% { transform: translate(0, 0) }
  10% { transform: translate(-8px, 4px) } 20% { transform: translate(8px, -4px) }
  30% { transform: translate(-7px, -3px) } 40% { transform: translate(7px, 3px) }
  50% { transform: translate(-5px, 2px) } 60% { transform: translate(5px, -2px) }
  70% { transform: translate(-3px, -1px) } 80% { transform: translate(3px, 1px) } 90% { transform: translate(-1px, 0) }
}
body.wizz-shake { animation: wizz-shake .7s ease-in-out; }
@media (prefers-reduced-motion: reduce) { body.wizz-shake { animation: none; } }
@media (max-width: 640px) { .emoji-panel { width: 280px; left: auto; right: 0; } .emoji-grid { grid-template-columns: repeat(7, 1fr); } }
