:root {
  --blue: #2a4088; --blue-d: #1e2f68; --blue-l: #e8edf8; --orange: #e0643c; --orange-l: #fdeee8;
  --bg: #f4f6fb; --card: #ffffff; --ink: #1d2433; --muted: #5d667a; --line: #e2e6ef;
  --good: #1d8556; --good-l: #e4f4ec; --warn: #b8730a; --warn-l: #fdf3e1; --crit: #c23a3a; --crit-l: #fbe9e9;
  --r: 10px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
h1 { font-size: 20px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; } .hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; } .boot img { width: 260px; opacity: .9; }

/* ---------- connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, #fff 0%, var(--blue-l) 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 32px 28px; }
.auth-card img { width: 230px; display: block; margin: 0 auto 6px; }
.auth-card .tag { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 13px; }

/* ---------- formulaires */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); padding: 9px 11px; border: 1px solid #cdd3e0;
  border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(42, 64, 136, .25); border-color: var(--blue); }
textarea { min-height: 120px; resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--blue); background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--blue-d); } .btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; color: var(--blue); } .btn.ghost:hover { background: var(--blue-l); }
.btn.orange { background: var(--orange); border-color: var(--orange); } .btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: #fff; color: var(--crit); border-color: #e7b9b9; }
.btn.block { width: 100%; justify-content: center; margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; } .row > * { flex: 1 1 160px; }
.err { color: var(--crit); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- structure */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .logo { padding: 18px 18px 10px; } .side .logo img { width: 180px; }
.side nav { flex: 1; overflow: auto; padding: 6px 10px; }
.side nav a, .sheet a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.side nav a:hover { background: var(--bg); }
.side nav a.on { background: var(--blue-l); color: var(--blue); font-weight: 700; }
.sheet .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 10px 4px; }
.side nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 10px 3px; }
.badge { margin-left: auto; background: var(--crit); color: #fff; border-radius: 20px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.badge.w { background: var(--warn); }
.side .me { border-top: 1px solid var(--line); padding: 12px 16px; font-size: 12px; }
.side .me b { display: block; font-size: 13px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; }
.banner { position: sticky; top: 0; z-index: 5; background: var(--blue); color: #fff; padding: 10px 24px;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap; box-shadow: 0 2px 6px rgba(20, 30, 60, .18); cursor: pointer; }
.banner .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; opacity: .8; }
.banner .big { font-size: 22px; font-weight: 700; } .banner .big small { font-size: 13px; font-weight: 600; opacity: .85; }
.banner .part { font-size: 12px; opacity: .92; } .banner .part b { font-size: 14px; display: block; }
.banner .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); display: inline-block; margin-right: 6px; }
.page { padding: 22px 24px 40px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; } .page-head select { width: auto; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; } .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .t { font-size: 12px; color: var(--muted); font-weight: 600; } .kpi .v { font-size: 19px; font-weight: 700; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hl { border-color: var(--orange); background: var(--orange-l); } .kpi.hl .v { color: #b4441e; }
.bar-track { height: 6px; background: var(--line); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--good); }

/* ---------- tableaux */
.tbl-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
  padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; background: #fff; position: sticky; top: 0; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f8f9fd; }
tr.tot td { font-weight: 700; background: #f7f8fc; border-top: 2px solid var(--line); }
tr.off td { color: #9aa1b1; text-decoration: line-through; }
.neg { color: var(--crit); } .pos { color: var(--good); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.pill.critique { background: var(--crit-l); color: var(--crit); } .pill.verifier { background: var(--warn-l); color: var(--warn); }
.pill.info { background: var(--blue-l); color: var(--blue); } .pill.ok { background: var(--good-l); color: var(--good); }
.pill.grey { background: #eef0f5; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--blue); border-color: var(--blue); }

/* ---------- alertes */
.alert { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.alert.critique { border-left-color: var(--crit); } .alert.verifier { border-left-color: var(--warn); }
.alert.classee { opacity: .6; } .alert .t { font-weight: 700; margin: 4px 0; }
.alert .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.alert .rep { background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-top: 8px; font-size: 13px; }
.alert .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.note { word-break: break-word; background: var(--blue-l); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--blue-d); margin-bottom: 14px; }
.note.w { background: var(--warn-l); color: #7a4c06; } .note.c { background: var(--crit-l); color: #8a2525; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* ---------- graphiques */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 92px; gap: 8px; align-items: center; margin: 7px 0; font-size: 12.5px; }
.hbar .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.hbar .trk { height: 16px; background: var(--blue-l); border-radius: 4px; position: relative; overflow: hidden; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--good); border-radius: 4px; }

/* ---------- modale, toast, mobile */
.modal { position: fixed; inset: 0; background: rgba(15, 22, 45, .45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; max-height: 88vh; overflow: auto; padding: 20px; }
.modal-box.wide { max-width: 920px; }
.modal-box .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
#toast { visibility: hidden; opacity: 0; position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 10px; z-index: 60; transition: transform .25s; max-width: 90vw; font-size: 13px; }
#toast.on { transform: translateX(-50%) translateY(0); visibility: visible; opacity: 1; } #toast.err { background: var(--crit); }
.mob-nav, .mob-top { display: none; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 16px 16px 0 0; padding: 14px 14px calc(70px + var(--safe-b));
  z-index: 40; box-shadow: 0 -6px 24px rgba(0, 0, 0, .15); max-height: 82vh; overflow-y: auto; }
.sheet-bg { position: fixed; inset: 0; background: rgba(15, 22, 45, .35); z-index: 39; }

@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .side { display: none; }
  .mob-top { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px; background: #fff; border-bottom: 1px solid var(--line); }
  .mob-top img { height: 30px; }
  .banner { padding: 8px 14px; gap: 14px; position: sticky; top: 0; } .banner .big { font-size: 18px; } .banner .part { display: none; }
  .page { padding: 14px 12px calc(90px + var(--safe-b)); }
  .g2, .g3 { grid-template-columns: 1fr; } .kpis, .kpis.k4 { grid-template-columns: 1fr 1fr; gap: 8px; } .kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi .v { font-size: 16px; }
  .mob-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 45;
    padding-bottom: var(--safe-b); }
  .mob-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 10.5px; color: var(--muted); text-decoration: none; position: relative; }
  .mob-nav a.on { color: var(--blue); font-weight: 700; } .mob-nav svg.i { width: 22px; height: 22px; }
  .mob-nav .badge { position: absolute; top: 3px; left: 54%; }
  .hbar { grid-template-columns: 96px 1fr 78px; }
  .page-head h1 { font-size: 18px; }
}
@media print {
  .side, .banner, .mob-nav, .mob-top, .page-head .tools, .btn { display: none !important; }
  .shell { display: block; } .card { box-shadow: none; break-inside: avoid; }
}

/* recouvrement complet de la société */
.card.rep table tr.sub td{color:#4a5470;font-size:.92em;border-top:none}
.card.rep .ind{padding-left:18px;display:inline-block}
.card.rep .ind::before{content:"↳ ";color:#9aa3b8}
.card.rep tr.tot td{border-top:2px solid #2a4088;background:#f4f6fb}
.banner .part .lbl.sm{display:block;opacity:.85;font-size:.8em;margin-top:2px}
@media (max-width: 760px) {
  .card.rep th:nth-child(2), .card.rep td:nth-child(2), .card.rep th:nth-child(5), .card.rep td:nth-child(5) { display: none; }
  .card.rep .ind { padding-left: 8px; }
}

/* compte de la société */
.cbar{display:grid;grid-template-columns:260px 1fr 190px;gap:14px;align-items:center;padding:10px 0;border-bottom:1px solid #eef0f5}
.cbar:last-child{border-bottom:none}
.cbar .cl{display:flex;flex-direction:column;gap:2px}
.cbar .trk{height:22px;background:#eef1f7;border-radius:6px;overflow:hidden}
.cbar .fill{height:100%;border-radius:6px}
.cbar .num b{font-size:18px}
tr.ret td{background:#fdf1ec}
.note.ok{background:#e8f5ee;border-color:#1d8556;color:#14603e}
@media (max-width: 760px){.cbar{grid-template-columns:1fr auto}.cbar .trk{grid-column:1/-1;order:3}}

/* recherche des polices */
.card.search{padding:12px 14px}
.sbar{display:flex;align-items:center;gap:10px;border:1.5px solid #2a4088;border-radius:10px;padding:4px 12px;background:#fff}
.sbar .i{width:20px;height:20px;stroke:#2a4088;flex:0 0 auto}
.sbar input{border:none;outline:none;font-size:16px;padding:8px 0;box-shadow:none;background:transparent}
/* classement */
.card.filtres .row>div{flex-basis:150px}
.podium{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;margin-bottom:16px}
.pod{background:#fff;border-radius:12px;padding:16px;border:1px solid #e3e7f0;text-align:center;position:relative}
.pod .rang{width:34px;height:34px;border-radius:50%;margin:0 auto 8px;display:flex;align-items:center;justify-content:center;font-weight:700;color:#fff;background:#9aa3b8}
.pod.or .rang{background:#d4a017}.pod.argent .rang{background:#8e9aaf}.pod.bronze .rang{background:#b0703a}.pod.bas .rang{background:#c23a3a}
.pod.or{border-color:#d4a017;box-shadow:0 2px 10px rgba(212,160,23,.18)}
.pod .nm{font-weight:700;font-size:15px}.pod .v{font-size:22px;font-weight:700;color:#2a4088;margin-top:8px}
tr.top td{background:#fafbfe}
.pos{color:#1d8556}
/* charges et taxes */
tr.vide td{color:#9aa3b8}
.trk.stack{display:flex}.trk.stack .fill{border-radius:0}
/* banques */
.card.rel.critique{border-left:4px solid #c23a3a}.card.rel.verifier{border-left:4px solid #b8730a}.card.rel.info{border-left:4px solid #2a4088}
table.etat td{padding:7px 10px}table.etat tr.tot td{border-top:2px solid #2a4088;background:#f4f6fb}
table.etat tr.bad td{background:#fbeaea;color:#8a2525}table.etat tr.good td{background:#e8f5ee;color:#14603e}
.pill.info{background:#e7ecf8;color:#2a4088}.pill.grey{background:#eef0f4;color:#5a6478}
@media (max-width:760px){.podium{grid-template-columns:1fr}.pod .small{display:none}.pod{display:grid;grid-template-columns:auto 1fr auto;gap:10px;align-items:center;text-align:left;padding:10px 14px}.pod .rang{margin:0}.pod .v{margin:0;font-size:18px}}

.kpi.hl2{border:1.5px solid #2a4088;background:#f4f6fb}

/* saisie */
.saisie-types{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}
.saisie-types .st{padding:10px 14px;border-radius:10px;border:1.5px solid #d5dbe8;background:#fff;color:#2a4088;font-weight:600;text-decoration:none}
.saisie-types .st.on{background:#2a4088;color:#fff;border-color:#2a4088}
/* fin de mois */
table.fmt{width:100%;border-collapse:collapse;margin-bottom:12px}table.fmt th{background:#aebbd4;color:#1d2a4a;text-align:center;padding:6px;border:1px solid #333}
table.fmt td{border:1px solid #333;padding:5px 8px;font-weight:600}table.fmt tr.tot td{background:#aebbd4}
.card.fm .fml{margin-bottom:6px}.card.fm .fml input{margin:0}
.kpi.bad{border:1.5px solid #c23a3a;background:#fbeaea}
tr.off td{opacity:.5;text-decoration:line-through}

.kpis.k7{grid-template-columns:repeat(7,minmax(0,1fr))}
@media (max-width:1500px){.kpis.k7{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media (max-width:760px){.kpis.k7{grid-template-columns:1fr 1fr}}

/* ---------------------------------------------------------------- assistant */
.main { position: relative; }
.ia-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--blue);
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 20px; cursor: pointer; box-shadow: 0 2px 8px rgba(15, 22, 45, .12); }
.ia-btn .i { width: 16px; height: 16px; }
.ia-btn:hover { background: #f2f5fb; }
.ia-btn.desk { position: fixed; top: 10px; right: 18px; z-index: 7; }
.ia-btn.mob { padding: 4px 10px; font-size: 12px; box-shadow: none; }
.ia-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: #fff; z-index: 45; display: flex; flex-direction: column;
  box-shadow: -8px 0 28px rgba(15, 22, 45, .2); }
.ia-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; border-bottom: 1px solid var(--line); background: var(--blue); color: #fff; }
.ia-head .muted { color: rgba(255, 255, 255, .8); }
.ia-head .btn { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .4); }
.ia-fil { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: #f6f8fc; }
.ia-msg { padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; max-width: 92%; }
.ia-msg.bot { background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.ia-msg.moi { background: var(--blue); color: #fff; align-self: flex-end; }
.ia-msg.err { background: #fdecea; color: var(--crit); align-self: flex-start; }
.ia-msg.attente { color: var(--muted); font-style: italic; }
.ia-form { padding: 10px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.ia-form textarea { min-height: 64px; resize: vertical; }
.ia-bas { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.ia-coches { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 8px; }
.ia-coches label { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; font-weight: 400; }
.ia-coches input { width: auto; }
@media (min-width: 901px) { .banner { padding-right: 230px; } .main.sans-banniere .page { padding-top: 56px; } }
@media (max-width: 900px) { .ia-btn.desk { display: none !important; } }
input:disabled, select:disabled, textarea:disabled { background: #eef0f4; color: var(--muted); cursor: not-allowed; }
