/* Portefeuille Assurances — styles de l'application (CRM + écrans d'accès SaaS) */
/* Layout: outil sobre — barre latérale blanche, espace de travail neutre, fiche client en panneau latéral */
/* Thème clair unique, volontaire : fond lumineux, texte anthracite doux, un seul bleu atténué */
:root {
  --bg: #E1E8F2; --surface: #EDF2F9; --sunk: #DAE2EE; --ink: #36404F; --strong: #29323F; --muted: #74819A; --line: #D0D9E6;
  --accent: #4F6CD4; --accent-ink: #EDF2F9; --accent-soft: #D8E1F6;
  --ok: #3E8E63; --ok-soft: #E2EEE7; --warn: #A87228; --warn-soft: #F1EADF; --danger: #C0645A; --danger-soft: #F2E4E2;
  --f-display: "Geist", "Segoe UI", system-ui, sans-serif;
  --f-body: "Geist", "Segoe UI", system-ui, sans-serif;
  --f-data: "Geist Mono", ui-monospace, Consolas, monospace;
  --r: 12px;
  --shadow: 0 1px 2px rgba(58, 61, 69, 0.03);
  color-scheme: light;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -0.02em; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--f-data); font-variant-numeric: tabular-nums; }
p { margin: 0; }

.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: env(safe-area-inset-top, 0px); height: 100vh; }
.brand { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.brand b { font-family: var(--f-display); font-size: 19px; font-weight: 700; line-height: 1.1; }
.brand span { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { all: unset; cursor: pointer; padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; }
.nav button:hover { background: var(--surface); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
.nav button:focus-visible { outline: 2px solid var(--accent); }
.nav .count { font-family: var(--f-data); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.nav .count.alert { color: var(--danger); font-weight: 500; }
.nav .sep { height: 1px; background: var(--line); margin: 6px 10px; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; display: flex; flex-direction: column; gap: 8px; }

main { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top h1 { font-size: 28px; font-weight: 700; }
.top p { margin: 2px 0 0; color: var(--muted); max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--sunk); }
.btn.danger { color: var(--danger); }
.btn.danger.armed { background: var(--danger); color: var(--surface); border-color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
a.btn { text-decoration: none; display: inline-block; }

.banner { background: var(--warn-soft); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; font-size: 13px; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.kpi .val { font-family: var(--f-display); font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-width: 0; }
.panel > header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 14px 16px 10px; flex-wrap: wrap; }
.panel > header h2 { font-size: 16px; font-weight: 700; }
.panel > header span { color: var(--muted); font-size: 12.5px; }
.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 16px; border-top: 1px solid var(--line); align-items: center; cursor: pointer; }
.row:hover { background: var(--sunk); }
.row .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 12.5px; grid-column: 1; }
.row .end { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; align-items: center; }
.empty { padding: 18px 16px 20px; color: var(--muted); border-top: 1px solid var(--line); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.prospect { background: var(--sunk); color: var(--muted); }
.pill.rdv { background: var(--accent-soft); color: var(--accent); }
.pill.devis { background: var(--warn-soft); color: var(--warn); }
.pill.client { background: var(--ok-soft); color: var(--ok); }
.pill.perdu { background: var(--danger-soft); color: var(--danger); }
.chip { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.late { color: var(--danger); border-color: var(--danger); }
.chip.soon { color: var(--warn); border-color: var(--warn); }
.chip.opp, .chip.in { color: var(--accent); border-color: var(--accent); }
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.ex { border-style: dashed; }

.funnel { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--sunk); }
.bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.legend b { color: var(--ink); font-family: var(--f-data); font-weight: 500; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { flex: 1 1 220px; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 70px; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fgrid .wide { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--sunk); }
tbody tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.sub2 { color: var(--muted); font-size: 12.5px; }

.board { display: grid; grid-template-columns: repeat(5, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 140px; }
.col h3 { font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 2px 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.card:hover { border-color: var(--muted); }
.card .nm { font-weight: 600; }
.card .ln { font-size: 12.5px; color: var(--muted); }
.card .mv { display: flex; justify-content: space-between; gap: 6px; }

/* Agenda */
.day { display: flex; flex-direction: column; }
.day > h3 { font-size: 13px; text-transform: capitalize; padding: 12px 16px 6px; color: var(--muted); font-family: var(--f-body); font-weight: 600; border-top: 1px solid var(--line); }
.day:first-child > h3 { border-top: 0; }
.ev { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 16px; align-items: center; cursor: pointer; }
.ev:hover { background: var(--sunk); }
.ev .h { font-family: var(--f-data); font-size: 12.5px; }
.ev .t { min-width: 0; }
.ev .t b { font-weight: 600; }
.ev .t div { color: var(--muted); font-size: 12.5px; }

/* Apporteurs & réglages */
.apgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; align-items: start; }
.ap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ap h3 { font-size: 17px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ap .stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ap .stats div { display: flex; flex-direction: column; }
.ap .stats b { font-family: var(--f-data); font-weight: 500; font-size: 15px; }
.ap .stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.copyrow { display: flex; gap: 6px; align-items: center; min-width: 0; }
.copyrow code { flex: 1; min-width: 0; font-family: var(--f-data); font-size: 12px; background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.names { display: flex; flex-wrap: wrap; gap: 6px; }
.names button { border: 1px solid var(--line); background: var(--sunk); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; cursor: pointer; }
.panel .pad { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.panel .pad p, .ap p { color: var(--muted); max-width: 72ch; }
ol.steps { margin: 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; max-width: 72ch; }
ol.steps b { color: var(--ink); }
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 860px; }

/* Fiche client */
.scrim { position: fixed; inset: 0; background: rgba(8, 18, 22, 0.42); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--bg); border-left: 1px solid var(--line); z-index: 21; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.d-head { padding: 16px 20px 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); background: var(--surface); }
.d-head .t { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.d-head h2 { font-size: 22px; font-weight: 700; }
.d-head .contact { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.d-head .contact span { user-select: all; }
.d-head .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.d-head .st { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.d-head .st select { width: auto; }
.d-body { overflow-y: auto; padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 16px; }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.sec > h3 { font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sec > h3 small { font-family: var(--f-body); font-weight: 500; color: var(--muted); font-size: 12.5px; }
.sec.conc { background: var(--sunk); border-style: dashed; }
.sec.conc .contract { background: var(--surface); }
.klist { display: flex; flex-direction: column; gap: 8px; }
.contract { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.contract .l1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.contract .l1 b { font-size: 14.5px; }
.contract .l2 { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.contract .l3 { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.contract.off { opacity: 0.6; }
details.add > summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 10px; }
.hist ul { margin: 0; padding: 0; }
.hist li { list-style: none; display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: start; }
.hist li:first-child { border-top: 0; }
.hist .d { font-family: var(--f-data); font-size: 12px; color: var(--muted); padding-top: 2px; }
.hist .k { font-weight: 600; font-size: 12.5px; }
.hist .x { white-space: pre-wrap; overflow-wrap: anywhere; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.lien { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); cursor: pointer; }
.lien:first-child { border-top: 0; }
.lien:hover b { color: var(--accent); }
.lien .role { font-size: 12.5px; color: var(--muted); }
.lien b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail { border-top: 1px solid var(--line); padding: 8px 0; }
.mail:first-child { border-top: 0; }
.mail summary { cursor: pointer; list-style: none; display: grid; grid-template-columns: 92px auto minmax(0, 1fr); gap: 4px 10px; align-items: baseline; }
.mail summary::-webkit-details-marker { display: none; }
.mail .d { font-family: var(--f-data); font-size: 12px; color: var(--muted); }
.mail .obj { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail .res { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; }
.mail .body { margin: 8px 0 2px 102px; padding: 10px 12px; background: var(--sunk); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; max-height: 320px; overflow-y: auto; }
.mail .mfoot { display: flex; justify-content: flex-end; margin-top: 4px; }
.rdvs { display: flex; flex-direction: column; }
.rdvi { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); }
.rdvi:first-child { border-top: 0; }
.rdvi.past { opacity: 0.6; }
.rdvi .when { font-family: var(--f-data); font-size: 12.5px; }
.rdvi .act { display: flex; gap: 4px; align-items: center; }
.synth { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.synth.placeholder { color: var(--muted); }
.stale { font-size: 12.5px; color: var(--warn); }
textarea.copybox { font-family: var(--f-data); font-size: 12px; min-height: 120px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 8px; z-index: 40; font-size: 13px; max-width: calc(100% - 32px); }

/* Compagnies & produits */
.ciegrid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.cielist .rows { max-height: 520px; overflow-y: auto; }
.cierow { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 1px; padding: 9px 16px; border-top: 1px solid var(--line); width: 100%; }
.cierow:hover { background: var(--sunk); }
.cierow[aria-current="true"] { background: var(--accent-soft); }
.cierow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cierow b { font-weight: 600; }
.cathead { font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 6px; letter-spacing: 0; }
.prow { display: grid; grid-template-columns: 30px minmax(0, 1fr) 120px 150px 130px; gap: 10px; align-items: center; padding: 5px 0; border-top: 1px solid var(--line); }
.prow.head { border-top: 0; font-size: 12px; color: var(--muted); padding-bottom: 2px; }
.prow .pn { color: var(--muted); }
.prow.on .pn { color: var(--strong); font-weight: 500; }
.tick { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--muted); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 13px; line-height: 1; padding: 0; color: var(--accent-ink); user-select: none; }
.tick[data-state="1"] { background: var(--accent); border-color: var(--accent); }
.tick[data-state="2"] { background: transparent; border-color: transparent; color: var(--warn); font-size: 20px; }
.pct { display: flex; align-items: center; gap: 4px; }
.pct input { width: 76px; padding: 4px 8px; text-align: right; font-family: var(--f-data); font-size: 13px; }
.pct span { color: var(--muted); font-size: 12.5px; }
.catgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 4px 16px 16px; }
.catcol { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.catcol h3 { font-size: 14px; }
.catcol ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.catcol li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 4px 0; border-top: 1px solid var(--line); }
.catcol li:first-child { border-top: 0; }
.matrix th, .matrix td { text-align: center; padding: 6px 10px; font-size: 13px; }
.matrix th:first-child, .matrix td:first-child { text-align: left; white-space: nowrap; }
.matrix tbody tr { cursor: default; }
.matrix .grp td { font-weight: 600; color: var(--accent); background: var(--sunk); text-align: left; }
.matrix .ok { color: var(--accent); }
.matrix .star { color: var(--warn); font-size: 15px; }
.k-assist { font-size: 12.5px; color: var(--muted); }
.k-assist:empty { display: none; }
.linkbtn { all: unset; cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 500; }
.linkbtn:focus-visible { outline: 2px solid var(--accent); }

.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.f > span:first-child { font-size: 12px; color: var(--muted); font-weight: 500; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Tableau de bord compagnies & produits */
.dgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cattiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cattile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.cattile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cattile .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.cattile .val { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; color: var(--strong); font-variant-numeric: tabular-nums; }
.cattile .share { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.cattile .share i { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }
.bars { display: flex; flex-direction: column; gap: 2px; padding: 4px 16px 16px; }
.brow { display: grid; grid-template-columns: minmax(90px, 32%) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 4px; border-radius: 6px; cursor: default; }
.brow:hover, .brow:focus-visible { background: var(--sunk); outline: none; }
.brow .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.brow .bt { height: 12px; background: var(--sunk); border-radius: 2px; overflow: hidden; }
.brow .bt i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.brow.other .bt i { background: var(--muted); opacity: 0.5; }
.brow .bv { font-size: 12.5px; text-align: right; white-space: nowrap; }
.brow .bv span { color: var(--muted); }
table.heat td, table.heat th { text-align: center; padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
table.heat th:first-child, table.heat td:first-child { text-align: left; }
table.heat tbody tr { cursor: default; }
table.heat td.cell { font-family: var(--f-data); font-variant-numeric: tabular-nums; border-left: 2px solid var(--surface); }
table.heat td.zero { color: var(--muted); opacity: 0.6; }
table.heat .tot { font-weight: 600; color: var(--strong); }
.heatlegend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.heatlegend i { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 6%, var(--surface)), color-mix(in oklab, var(--accent) 48%, var(--surface))); }
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--strong); color: var(--surface); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; max-width: 260px; line-height: 1.45; white-space: pre-line; box-shadow: 0 4px 14px rgba(41, 50, 63, 0.18); }
@media (max-width: 1100px) { .dgrid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .cattiles { grid-template-columns: minmax(0, 1fr); } }

/* Gestion du cabinet */
table.fin td, table.fin th { white-space: nowrap; }
table.fin tbody tr { cursor: default; }
table.fin td.pos { color: var(--ok); }
table.fin td.neg { color: var(--danger); }
table.fin tr.total td { font-weight: 600; color: var(--strong); background: var(--sunk); }
.postes { display: flex; flex-direction: column; }
.poste { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 10px 16px; border-top: 1px solid var(--line); align-items: center; }
.poste b { font-weight: 600; color: var(--strong); }
.poste .act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.docs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.docs a.chip { text-decoration: none; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.docs .x { all: unset; cursor: pointer; color: var(--muted); font-size: 12px; padding: 0 2px; }
.docs .x:hover { color: var(--danger); }
table.lettrage input.occmt { width: 96px; padding: 3px 6px; text-align: right; font-family: var(--f-data); font-size: 12.5px; }
details.fees > summary { list-style: none; cursor: pointer; }
details.fees > summary::-webkit-details-marker { display: none; }
details.fees > summary .lnk { color: var(--accent); font-size: 12px; margin-left: 6px; }
table.mini { margin: 6px 0 2px; }
table.fin tr.prev td { color: var(--muted); font-style: italic; }
table.fin tr.prev td:first-child { font-style: normal; }
table.mini tr.cur td { background: var(--accent-soft); }
details.phist > summary { list-style: none; cursor: pointer; padding-top: 4px; }
details.phist > summary::-webkit-details-marker { display: none; }
details.phist .lnk, details.fees .lnk { color: var(--accent); font-size: 12.5px; font-weight: 500; }
select.occmode { width: auto; padding: 3px 6px; font-size: 12.5px; }
/* Colonnes alignées d'un tableau à l'autre (charges, entrées, fournisseurs) */
/* Chaque tableau fixe sa largeur minimale (style inline) : la colonne du libellé garde au moins ~220 px, le tableau défile sur petit écran */
table.cols { table-layout: fixed; width: 100%; }
table.cols th, table.cols td { text-align: left; vertical-align: top; overflow-wrap: break-word; white-space: normal; }
table.cols th.r, table.cols td.r { text-align: right; }
table.cols .c-chk { width: 40px; }
table.cols .c-cat { width: 160px; }
table.cols .c-tiers { width: 135px; }
table.cols .c-date { width: 120px; }
table.cols .c-mode { width: 120px; }
table.cols .c-docs { width: 190px; }
table.cols .c-mt { width: 120px; }
table.cols .c-ryt { width: 180px; }
table.cols .c-act { width: 170px; }
table.cols .c-orig { width: 130px; }
table.cols .c-via { width: 180px; }
table.cols input.ltdate { width: 100%; }
table.cols select.occmode { width: 100%; }
table.cols td.c-act .act { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
table.cols td.c-mt .sub2 { text-align: right; }
table.postes-t tr.ptr td { border-bottom: 0; padding-bottom: 2px; }
table.postes-t tr.htr td { padding-top: 0; }
b.lib { font-weight: 600; color: var(--strong); }
table.cols .c-ed { width: 46px; text-align: center; }
[hidden] { display: none !important; }
/* Menu : intitulé sur une ligne, compteur en dessous en plus petit ; sections titrées */
.nav button { flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; }
.nav .nl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav .count { font-size: 11px; line-height: 1.2; }
.nav .count:empty { display: none; }
/* première section : compteur en bout de ligne (sauf Tableau de bord, dont le compteur est un texte) */
.nav button.inl { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.nav button.inl .nl { flex: 1 1 auto; min-width: 0; }
.nav button.inl .count { font-size: 12px; flex: none; }
.nav .sep { margin: 10px 10px 2px; }
.nav-sec.nav-first { padding-top: 4px; }
.nav button.idle:not([aria-current]) .nl { color: var(--muted); opacity: 0.6; }
.panel.idle { opacity: 0.65; box-shadow: none; }
.notaux .pct, .notaux .prow.head span:nth-child(n+3), .notaux label.f:has(> [data-cf="decalage"]), .notaux label.f:has(> [data-cf="jourPaiement"]) { display: none !important; }
.notaux .prow { grid-template-columns: 30px minmax(0, 1fr); }
.modrow { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.modrow:first-of-type { border-top: 0; }
.modrow input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.modrow b { color: var(--strong); }
.panel.idle h2 { color: var(--muted); }
.nav-sec { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 4px; }
.brand b { overflow-wrap: anywhere; }
@media (max-width: 760px) { .nav-sec { display: none; } .nav button { flex: none; } }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rolechip { font-size: 11.5px; }
/* Bulle « Mon compte » et panneau du compte */
.acct { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.acct:hover { border-color: var(--accent); }
.acct:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; letter-spacing: 0.02em; background-size: cover; background-position: center; }
.acct-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.acct-t b { font-weight: 600; color: var(--strong); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-t span { font-size: 11.5px; color: var(--muted); }
.acct-drawer { width: min(460px, 100%); }
/* panneaux latéraux au-dessus du bandeau d'essai (version SaaS) */
.scrim { z-index: 35; }
.drawer { z-index: 36; }
.acct-drawer .av { width: 48px; height: 48px; font-size: 17px; }
.acct-head { display: flex; gap: 14px; align-items: center; }
@media (max-width: 760px) { .acct { padding: 6px 8px; } .acct .av { width: 28px; height: 28px; font-size: 11px; } }
output.ttc-out { display: block; padding: 7px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--strong); font-weight: 600; font-size: 15px; }
.iconbtn { all: unset; box-sizing: border-box; cursor: pointer; width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 7px; color: var(--muted); }
.iconbtn:hover, .iconbtn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); }
.iconbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.vdetail { display: flex; flex-direction: column; gap: 12px; padding: 8px 4px 6px; }
.brow.go { cursor: pointer; }
.brow.go:hover .bl { color: var(--accent); }
table.mini td, table.mini th { padding: 4px 8px; font-size: 12px; }

/* Commissions & lettrage */
.cfilters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.cfilters .f { flex: 0 1 170px; }
details.mois { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
details.mois > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
details.mois > summary::-webkit-details-marker { display: none; }
details.mois > summary::before { content: "›"; color: var(--muted); font-size: 18px; line-height: 1; transition: transform 0.15s; }
details.mois[open] > summary::before { transform: rotate(90deg); }
details.mois > summary b { font-weight: 600; text-transform: capitalize; min-width: 130px; color: var(--strong); }
details.mois .tot { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); flex: 1; }
details.mois .tot .num { color: var(--ink); }
details.mois .tot .reste { color: var(--danger); }
details.mois .tot .solde { color: var(--ok); }
table.lettrage tbody tr { cursor: default; }
table.lettrage td { padding: 7px 14px; }
table.lettrage tr.paid td { color: var(--muted); }
table.lettrage tr.paid .num { text-decoration: line-through; text-decoration-color: var(--muted); }
table.lettrage tr.grp td { background: var(--sunk); font-weight: 600; font-size: 12.5px; color: var(--accent); }
table.lettrage input.ltdate { width: 140px; padding: 3px 6px; font-size: 12.5px; font-family: var(--f-data); }
table.bxres td { vertical-align: top; font-size: 13px; }
table.bxres tbody tr { cursor: default; }
table.bxres tr.off td { opacity: 0.55; }
.bxsum { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.bxsum b { color: var(--strong); font-weight: 600; }
table.lettrage input[type=checkbox], table.bxres input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.cname { cursor: pointer; }
.cname:hover { color: var(--accent); }
.kpi .val.reste { color: var(--danger); }

/* Finitions sobres : moins de couleur, moins de traits, hiérarchie par la typographie */
.side { background: var(--surface); }
.brand b { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.nav button { font-weight: 500; }
.nav button:hover { background: var(--sunk); }
.nav button[aria-current="page"] { background: var(--sunk); box-shadow: none; }
.top h1 { font-size: 26px; }
.panel, .kpi, .sec, .ap, .card { box-shadow: var(--shadow); }
.kpi { padding: 16px 18px; gap: 6px; }
.kpi .val { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.kpi .lbl, th, .ap .stats span { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500; }
.panel > header h2 { font-size: 15px; font-weight: 600; }
.btn { box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: none; opacity: 0.9; }
h1, h2, h3, .kpi .val { color: var(--strong); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.toast { background: var(--strong); color: var(--surface); }
.scrim { background: rgba(58, 61, 69, 0.18); }
.drawer { box-shadow: -8px 0 24px rgba(58, 61, 69, 0.06); border-left-color: var(--line); }
.side { border-color: var(--line); }
.btn.ghost { box-shadow: none; }
.pill, .chip { font-weight: 500; }
.chip { border-radius: 6px; }
.banner { background: var(--sunk); }
.sec.conc { border-style: solid; }
.sec > h3 { font-size: 14.5px; font-weight: 600; }
.d-head h2 { font-size: 21px; }
.col { border-color: transparent; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.seg button { box-shadow: var(--shadow); }
.dot { border-radius: 50%; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid3 { grid-template-columns: minmax(0, 1fr); }
  .ciegrid { grid-template-columns: minmax(0, 1fr); }
  .catgrid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .prow { grid-template-columns: 30px minmax(0, 1fr); }
  .prow .pct { grid-column: 2; }
  .prow.head span:nth-child(n+3) { display: none; }
  .pct::before { content: attr(data-l); font-size: 12px; color: var(--muted); flex: 1; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px 10px; gap: 10px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .nav .sep { display: none; }
  .side-foot { display: none; }
  main { padding: 18px 16px 40px; }
  .top h1 { font-size: 23px; }
  .kpi .val { font-size: 22px; }
  .hide-sm { display: none; }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  .hist li { grid-template-columns: minmax(0, 1fr) auto; }
  .hist .d { grid-column: 1 / -1; }
  .lien { grid-template-columns: minmax(0, 1fr) auto auto; }
  .lien .role { grid-column: 1 / -1; }
  .mail summary { grid-template-columns: auto minmax(0, 1fr); }
  .mail .obj, .mail .res { grid-column: 1 / -1; }
  .mail .body { margin-left: 0; }
  .rdvi { grid-template-columns: minmax(0, 1fr) auto; }
  .rdvi .when { grid-column: 1 / -1; }
  .ap .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: slide 0.18s ease-out; }
  @keyframes slide { from { transform: translateX(24px); opacity: 0.6; } }
}
/* ---- Version SaaS : base de page, écrans d'accès, bandeau d'essai ---- */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.gate { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; }
.gate-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 10px 30px rgba(41, 50, 63, 0.08); }
.gate-card .brand { padding: 0; }
.gate-card h2 { font-size: 20px; }
.gate-card p { color: var(--muted); }
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-form .btn.primary, .gate-card > .btn.primary { padding: 10px 14px; text-align: center; }
.gate-card .seg { align-self: flex-start; }
.auth-msg { margin: 0; font-size: 13px; min-height: 1em; }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: var(--ok); }
.trialbar { position: sticky; top: 0; z-index: 30; background: var(--accent-soft); color: var(--ink); font-size: 13px; padding: 7px 16px; text-align: center; border-bottom: 1px solid var(--line); }
.trialbar a { color: var(--accent); font-weight: 600; }
.trialbar.urgent { background: var(--warn-soft); }
.plans { display: grid; gap: 10px; }
.plan { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.plan b { color: var(--strong); }
.plan span { font-size: 13px; color: var(--muted); }
.plan .btn { align-self: flex-start; }
.plan .price { color: var(--strong); font-weight: 600; font-size: 13px; }
.side-foot .who { display: flex; flex-direction: column; gap: 2px; }
.side-foot .who b { color: var(--ink); font-weight: 600; }

.envbadge { position: fixed; left: 12px; bottom: 12px; z-index: 70; background: var(--warn); color: #fff; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; letter-spacing: 0.02em; pointer-events: none; }
