/* ===== MIS Compta — charte commune avec MIS Atelier ===== */
@font-face { font-family: "Figtree"; font-weight: 400; font-display: swap; src: url(../fonts/figtree-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-display: swap; src: url(../fonts/figtree-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-display: swap; src: url(../fonts/figtree-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 700 900; font-display: swap; src: url(../fonts/figtree-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Bricolage"; font-weight: 700; font-display: swap; src: url(../fonts/bricolage-grotesque-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Bricolage"; font-weight: 800; font-display: swap; src: url(../fonts/bricolage-grotesque-latin-800-normal.woff2) format("woff2"); }

:root {
  --bg: #eef0f4; --surface: #ffffff; --surface-2: #f7f8fa; --line: #dde2ea; --line-2: #eef0f4;
  --text: #111827; --muted: #5b6475; --faint: #8a93a3;
  --navy: #0f172a; --accent: #1d4ed8; --accent-bg: #eef3ff; --accent-bd: #9db4f0;
  --brand: #c0007f; --brand-bg: #fdf0f8;
  --ok: #15803d; --ok-bg: #e9f8ef; --warn: #b45309; --warn-bg: #fdf3e6; --danger: #b91c1c; --danger-bg: #fdecec;
  --debit: #1d4ed8; --debit-bg: #eaf1ff; --credit: #c2410c; --credit-bg: #fff1e8;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 2px 10px rgba(15,23,42,.05);
  --display: "Bricolage", "Figtree", system-ui, sans-serif;
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.4; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.spacer { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- barre du haut ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 8px 20px; min-height: 60px; background: var(--navy); color: #e2e8f0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 18px; white-space: nowrap; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-family: "Figtree"; font-size: 11.5px; letter-spacing: .04em; color: #fff; }
.modules { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: #1e293b; }
.modules a, .modules span { padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: #e2e8f0; text-decoration: none; }
.modules .on { background: var(--brand); color: #fff; font-weight: 700; }
.modules .soon { color: #94a3b8; }
.modules .soon small { font-size: 10.5px; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; }
.nav a { color: #cbd5e1; text-decoration: none; padding: 8px 10px; font-size: 14px; border-radius: 8px; font-weight: 600; position: relative; }
.nav a:hover { background: #1e293b; }
.nav a.active { background: #1e293b; color: #fff; box-shadow: inset 0 -2px 0 var(--brand); }
.nav a .badge { position: absolute; top: -4px; right: -4px; background: #fbbf24; color: #451a03; font-size: 10.5px; font-weight: 800; padding: 0 6px; border-radius: 99px; }
.socsel { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px; border-radius: 9px; border: 1px solid #334155; background: #1e293b; color: #f1f5f9; font-weight: 600; font-size: 13.5px; }
.socsel select { background: transparent; border: 0; color: #f1f5f9; font-weight: 600; max-width: 180px; cursor: pointer; }
.socsel select option { color: #111827; }
.socsel .dot { width: 10px; height: 10px; border-radius: 50%; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #e2e8f0; white-space: nowrap; font-weight: 600; }
.btn-ghost-dark { background: transparent; border: 1px solid #334155; color: #cbd5e1; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 500; }
.btn-ghost-dark:hover { background: #1e293b; }
@media (max-width: 900px) { .topbar { position: static; } .modules { display: none; } }

/* ---------- page ---------- */
.page { max-width: 1360px; margin: 0 auto; padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.kicker { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
h1.title { font-family: var(--display); font-weight: 800; font-size: 28px; margin: 4px 0 0; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.panel > h2, h2.h { margin: 0 0 12px; font-family: var(--display); font-size: 18px; font-weight: 700; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- boutons, champs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #c3cad6; background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.brand { background: var(--brand); color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(192,0,127,.25); }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; box-shadow: 0 6px 18px rgba(21,128,61,.25); }
.btn.draft { background: #fbbf24; color: #451a03; border-color: transparent; box-shadow: 0 6px 18px rgba(180,83,9,.2); }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 52px; padding: 0 22px; font-size: 16px; font-weight: 800; border-radius: 12px; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary:hover, .btn.brand:hover, .btn.ok:hover, .btn.draft:hover { filter: brightness(1.06); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid #cfd6e1; background: var(--surface); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .cell:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29,78,216,.14); }
.readonly-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line); font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: #166534; }
.chip.warn { background: var(--warn-bg); color: #92400e; }
.chip.err { background: var(--danger-bg); color: #991b1b; }
.chip.info { background: var(--accent-bg); color: var(--accent); }
.jbadge { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; padding: 3px 8px; border-radius: 8px; color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tog { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.tog input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- tableaux ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f8faff; }
.tbl tr.sub td { background: #f7f8fc; font-weight: 700; font-size: 13px; }
.tbl tr.total td { background: var(--navy); color: #fff; font-weight: 700; }
.tbl tr.group td { padding-top: 16px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); border-bottom: 0; }
.tbl .acc { font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- tableau de bord ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.kpi .k { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #374151; }
.kpi .k i { width: 10px; height: 10px; border-radius: 3px; }
.kpi .v { font-family: var(--display); font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .n { font-size: 12.5px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 210px; border-bottom: 1px solid var(--line); padding-top: 10px; }
.bars .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; }
.bars .b { width: 12px; border-radius: 4px 4px 0 0; min-height: 1px; }
.bars .lab { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13px; color: #374151; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.todo li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line-2); }
.todo .cnt { min-width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 17px; }

/* ---------- saisie ---------- */
.steps { list-style: none; margin: 0; padding: 14px 18px; display: flex; flex-wrap: wrap; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps li { display: flex; align-items: center; gap: 10px; flex: 1 1 170px; font-weight: 600; color: var(--muted); font-size: 14px; }
.steps li b { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #e6e9f2; color: #374151; flex-shrink: 0; }
.steps li.cur { color: var(--text); }
.steps li.cur b { background: var(--accent); color: #fff; }
.steps li.done { color: var(--text); }
.steps li.done b { background: var(--ok); color: #fff; }
.jtiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.jtile { --c: #475569; display: flex; align-items: center; gap: 14px; min-height: 80px; padding: 12px 14px; border-radius: 16px; border: 2px solid color-mix(in srgb, var(--c) 18%, #fff); background: color-mix(in srgb, var(--c) 9%, #fff); text-align: left; cursor: pointer; }
.jtile .code { width: 54px; height: 54px; border-radius: 14px; background: var(--c); color: #fff; display: grid; place-items: center; font-family: var(--display); font-size: 20px; font-weight: 800; flex-shrink: 0; letter-spacing: .02em; }
.jtile .t { display: flex; flex-direction: column; gap: 2px; }
.jtile .t b { font-size: 16px; }
.jtile .t span { font-size: 12.5px; color: #374151; }
.jtile:hover { border-color: var(--c); }
.jtile.on { background: var(--c); border-color: var(--c); color: #fff; }
.jtile.on .code { background: #fff; color: var(--c); }
.jtile.on .t span { color: #fff; }
.docgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.docgrid .wide { grid-column: span 2; }
@media (max-width: 600px) { .docgrid .wide { grid-column: auto; } }

.lines { min-width: 940px; }
.lhead, .lrow { display: grid; grid-template-columns: 170px minmax(0, 1.4fr) minmax(0, 1fr) 150px 150px 40px; gap: 10px; align-items: center; padding: 8px 16px; }
.lhead { background: var(--surface-2); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lhead .num { text-align: right; }
.lrow { border-bottom: 1px solid var(--line-2); }
.lrow.auto { background: #fafbff; }
.band { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); }
.band b { font-family: var(--display); font-size: 15px; letter-spacing: .05em; }
.band span { font-size: 13px; color: #374151; }
.band.d { background: var(--debit-bg); } .band.d b { color: var(--debit); }
.band.c { background: var(--credit-bg); } .band.c b { color: var(--credit); }
.cell { width: 100%; min-height: 40px; padding: 6px 10px; border-radius: 9px; border: 1.5px solid #cfd6e1; background: #fff; }
.cell.acc { font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.cell.amt { text-align: right; font-weight: 700; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.cell.amt.computed { background: var(--accent-bg); border-color: var(--accent-bd); color: #1e3a8a; }
.accname { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.accname b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accname small { font-size: 12px; color: var(--accent); font-weight: 600; }
.accname.unknown b { color: var(--danger); }
.accname.vague b { color: var(--muted); font-weight: 500; }
.autoamt { display: flex; align-items: center; justify-content: flex-end; min-height: 40px; padding: 0 10px; border-radius: 9px; background: var(--accent-bg); border: 1px dashed var(--accent-bd); font-weight: 700; font-size: 15.5px; color: #1e3a8a; font-variant-numeric: tabular-nums; }
.autotag { display: inline-flex; margin-left: 8px; font-size: 10.5px; font-weight: 800; color: var(--accent); background: #dbe5ff; padding: 1px 7px; border-radius: 99px; vertical-align: 1px; }
.lockacc { display: flex; align-items: center; gap: 8px; padding: 0 10px; font-weight: 800; color: #1e3a8a; }
.rm { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.rm:hover { color: var(--danger); border-color: #f5b5b5; }
.addl { margin: 8px 16px 10px; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 11px; border: 2px dashed currentColor; background: #fff; font-weight: 700; cursor: pointer; }
.addl.d { color: var(--debit); } .addl.c { color: var(--credit); }
.totbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 20px; background: var(--navy); color: #fff; }
.totbar .t { display: flex; flex-wrap: wrap; gap: 26px; font-size: 14px; font-variant-numeric: tabular-nums; }
.totbar strong { font-size: 18px; margin-left: 6px; }
.eq { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 800; }
.eq.ok { background: #34d399; color: #052e1f; }
.eq.ko { background: #fca5a5; color: #450a0a; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.kbd { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #374151; }
kbd { font-family: inherit; font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 6px; background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; }

/* liste de suggestions de comptes */
.ac-box { position: fixed; z-index: 60; width: 380px; max-height: 320px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 36px rgba(15,23,42,.18); padding: 6px; }
.ac-box .opt { display: flex; gap: 10px; align-items: baseline; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ac-box .opt b { min-width: 86px; font-variant-numeric: tabular-nums; }
.ac-box .opt small { margin-left: auto; color: var(--accent); font-weight: 700; font-size: 11.5px; }
.ac-box .opt.sel, .ac-box .opt:hover { background: var(--accent-bg); }
.ac-box .new { color: var(--brand); font-weight: 700; }
.ac-box .foot { padding: 7px 10px 4px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); margin-top: 4px; }

/* ---------- onglets ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button, .tabs a { min-height: 40px; padding: 0 16px; border-radius: 99px; border: 1px solid #cfd6e1; background: #fff; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; }
.tabs .on { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 700; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filters .field { flex: 1 1 150px; }

/* ---------- fenêtre modale ---------- */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(15,23,42,.5); }
dialog form, dialog .dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; font-family: var(--display); font-size: 20px; }
dialog .btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- divers ---------- */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #0f172a; color: #f1f5f9; padding: 11px 15px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-size: 14px; max-width: 440px; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.alert.warn { background: var(--warn-bg); color: #92400e; border: 1px solid #f3d3a5; }
.alert.err { background: var(--danger-bg); color: #991b1b; border: 1px solid #f5b5b5; }
.alert.ok { background: var(--ok-bg); color: #166534; border: 1px solid #a7e3c0; }
.hero { border-radius: var(--radius); padding: 22px; background: #1e3a8a; color: #fff; display: flex; flex-direction: column; gap: 8px; }
.hero .big { font-family: var(--display); font-size: 40px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hero span { color: #dbe5ff; font-size: 14px; }
.ca3 td.ln { width: 60px; }
.ca3 td.ln span { display: inline-flex; min-width: 38px; justify-content: center; padding: 3px 6px; border-radius: 8px; background: var(--navy); color: #fff; font-size: 13px; font-weight: 800; }
.copy.ghost { visibility: hidden; }
.copy { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--accent); cursor: pointer; display: inline-grid; place-items: center; margin-left: 8px; vertical-align: middle; }
.lines-detail { background: #fafbfe; }
.lines-detail td { font-size: 13px; padding: 6px 10px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% 0%, #1e3a8a 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #86198f 0%, transparent 55%), #0b1120; padding: 16px; }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 18px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 12px; }
.login-card .brand { color: #0f172a; margin-bottom: 6px; }
.login-card .check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: #475569; }
.login-card .err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- impression des états ---------- */
.print-head { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  .topbar, .no-print, .toasts, .filters, .tabs, .head .btns { display: none !important; }
  .page { padding: 0; max-width: none; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .print-head { display: block; margin-bottom: 8px; }
  .tbl th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tbl tr.total td { background: #222 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tbl td, .tbl th { padding: 4px 6px; }
  .tbl-wrap { overflow: visible; }
}
