:root {
  color-scheme: light;
  --ink: #14232a; --muted: #56656d; --line: #d8e3e4; --paper: #f3f6f6; --card: #fff;
  --brand: #0e5c66; --accent: #0f6a72; --accent-dark: #0b545b; --accent-soft: #e2f3f1; --gold: #f2b84b;
  --danger: #a33131; --danger-soft: #fbeaea; --warn: #8a5a00; --warn-soft: #fff6e0; --good: #176b62;
  --serie-0: #2a78d6; --serie-1: #eb6834; --serie-2: #1baf7a; --serie-3: #eda100;
  --serie-4: #e87ba4; --serie-5: #008300; --serie-6: #6250d6; --serie-7: #e34948;
  --shadow: 0 6px 20px rgba(23, 33, 43, .05);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.5; }
h1, h2, h3 { letter-spacing: -.02em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; color: var(--ink); padding: 8px 12px; border-radius: 6px; z-index: 10; }
.skip:focus { left: 8px; }

/* En-tête */
.topbar { background: #fff; color: var(--ink); padding: 12px clamp(14px, 4vw, 48px); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 3px solid var(--brand); box-shadow: 0 2px 12px rgba(14, 92, 102, .06); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .wordmark { display: block; height: 56px; width: auto; }
.brand .brand-icon { display: none; border-radius: 10px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.privacy { font-size: 12px; color: var(--accent-dark); background: var(--accent-soft); border: 1px solid #bfe1dc; padding: 5px 10px; border-radius: 999px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; letter-spacing: .02em; }
[hidden] { display: none !important; }

/* Pages légales */
.legal { max-width: 760px; }
.legal h1 { font-size: 24px; }
.legal h2 { font-size: 17px; margin-top: 22px; }
.legal a { color: var(--accent-dark); }

/* Repères et conseils */
.plan { margin: 0; padding-left: 22px; display: grid; gap: 12px; }
.plan-item { padding: 12px 14px; background: #f7fbfb; border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 10px; }
.plan-item p { margin: 6px 0 0; }
.plan-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.gain { font-weight: 700; color: var(--accent-dark); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.plan-action { font-weight: 600; }
.cmp { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cmp p { margin: 0 0 6px; }
.cmp-row { display: grid; grid-template-columns: 56px minmax(80px, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; }
.cmp-track { height: 10px; background: #edf1f3; border-radius: 5px; position: relative; }
.cmp-fill { position: absolute; inset: 0 auto 0 0; border-radius: 5px; }
.cmp-fill.moi { background: var(--serie-0); }
.cmp-fill.ref { background: #8d99a1; }
.cmp-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
a.source { color: var(--accent-dark); font-size: 12px; overflow-wrap: anywhere; }
.sources { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 13px; }

/* Contrôles */
input, select, button, .button { font: inherit; border: 1px solid #b9c3cb; border-radius: 8px; padding: 8px 11px; background: #fff; color: var(--ink); min-height: 38px; max-width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible, .button:focus-visible, summary:focus-visible, .drop-zone:focus-within { outline: 3px solid #4fa89c; outline-offset: 2px; }
button, .button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover, .button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled { opacity: .45; cursor: default; }
button.secondary, .button.secondary { background: #fff; color: var(--ink); border-color: #7b8790; }
button.secondary:hover, .button.secondary:hover { background: #eef2f4; }
button.light { background: #fff; color: var(--brand); border-color: #fff; }
button.light:hover { background: #e4f1ee; }
button.ghost { background: transparent; color: var(--ink); border-color: transparent; text-decoration: underline; text-underline-offset: 2px; }
button.ghost:hover { background: #eef2f4; }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.small { min-height: 32px; padding: 4px 9px; font-size: 13px; }
button.icon { width: 38px; padding: 0; font-size: 20px; }

/* Barre du cycle */
.toolbar { max-width: 1440px; margin: 14px auto 0; padding: 10px clamp(12px, 3vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cycle { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cycle select { font-weight: 600; }
#status { font-size: 13px; color: var(--accent); }
#status[data-tone="erreur"] { color: var(--danger); }
.demo-banner { max-width: 1440px; margin: 8px auto 0; padding: 10px clamp(12px, 3vw, 32px); background: var(--warn-soft); color: var(--warn); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.demo-banner[hidden] { display: none; }

/* Onglets */
.tabs { max-width: 1440px; margin: 10px auto 0; padding: 0 clamp(12px, 3vw, 32px); display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab { background: transparent; border: 1px solid transparent; border-bottom: 0; color: var(--muted); border-radius: 8px 8px 0 0; white-space: nowrap; font-weight: 600; }
.tab:hover { background: #e9eef1; color: var(--ink); border-color: transparent; }
.tab.active { background: var(--card); color: var(--accent); border-color: var(--line); box-shadow: inset 0 3px 0 var(--accent); }
main { max-width: 1440px; margin: auto; padding: 18px clamp(12px, 3vw, 32px) 40px; }
.panel { display: none; }
.panel.active { display: block; }
.panel:focus { outline: none; }
.panel h2 { font-size: 18px; margin: 18px 0 10px; }
.panel h2:first-child { margin-top: 0; }

/* Cartes et grilles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
.card h3 { font-size: 14px; margin: 16px 0 8px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 14px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .grid-2, .grid-2 + .card, .kpis + .grid-2 { margin-top: 14px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .kpi-label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi strong { display: block; font-size: 24px; margin: 6px 0 4px; font-variant-numeric: tabular-nums; letter-spacing: -.03em; overflow-wrap: anywhere; }
.kpi small { color: var(--muted); font-size: 12px; display: block; }
.kpi.bon { border-top: 3px solid var(--good); }
.kpi.alerte { border-top: 3px solid var(--danger); }
.kpi.alerte strong { color: var(--danger); }
.muted { color: var(--muted); font-size: 13px; }
.notice { border-left: 3px solid #b07400; background: var(--warn-soft); color: #5e4300; padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.column { flex-direction: column; align-items: stretch; }
.onboarding { max-width: 760px; }
.onboarding ol { padding-left: 20px; }
.onboarding li { margin: 6px 0; }

/* À traiter */
.todo { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.todo strong { font-size: 22px; min-width: 36px; font-variant-numeric: tabular-nums; }
.todo span { flex: 1; }
.upcoming { list-style: none; margin: 0; padding: 0; }
.upcoming li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.upcoming .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.insight { padding: 10px 12px; border-radius: 8px; background: #f1f5f7; border-left: 3px solid #7b8790; }
.insight.bon { background: var(--accent-soft); border-left-color: var(--good); }
.insight.attention { background: var(--warn-soft); border-left-color: #b07400; color: #4d3700; }

/* Graphiques */
.chart-box { min-height: 120px; }
.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: #e7ebee; stroke-width: 1; }
.chart .axis-zero { stroke: #9aa5ad; stroke-width: 1; }
.chart .tick { fill: #55606a; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart rect { stroke: #fff; stroke-width: 1; }
.chart rect:hover { opacity: .8; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(23, 33, 43, .12); }
.chart .dot { stroke: #fff; stroke-width: 2; }
.serie-0 { fill: var(--serie-0); stroke: var(--serie-0); background: var(--serie-0); }
.serie-1 { fill: var(--serie-1); stroke: var(--serie-1); background: var(--serie-1); }
.serie-2 { fill: var(--serie-2); stroke: var(--serie-2); background: var(--serie-2); }
.serie-3 { fill: var(--serie-3); stroke: var(--serie-3); background: var(--serie-3); }
.serie-4 { fill: var(--serie-4); stroke: var(--serie-4); background: var(--serie-4); }
.serie-5 { fill: var(--serie-5); stroke: var(--serie-5); background: var(--serie-5); }
.serie-6 { fill: var(--serie-6); stroke: var(--serie-6); background: var(--serie-6); }
.serie-7 { fill: var(--serie-7); stroke: var(--serie-7); background: var(--serie-7); }
.chart .line[class*="serie-"] { fill: none; }
.chart rect[class*="serie-"] { stroke: #fff; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.chart-data { margin-top: 6px; font-size: 13px; }
.chart-data summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.chart-data table { min-width: 0; margin-top: 6px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) minmax(60px, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-label { overflow-wrap: anywhere; }
.hbar-track { position: relative; height: 12px; background: #edf1f3; border-radius: 6px; }
.hbar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--serie-0); border-radius: 6px; }
.hbar-fill.over { background: var(--serie-7); }
.hbar-limit { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.hbar-value { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.badge-over { color: var(--danger); }

/* Tableaux */
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-heading h2 { margin-bottom: 2px; }
.section-heading p { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type="search"] { flex: 1 1 200px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
table.compact { min-width: 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #e8ecef; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #f8fafb; }
td input, td select { width: 100%; min-width: 110px; padding: 5px 7px; min-height: 34px; font-size: 13px; }
td small { display: block; color: var(--muted); font-size: 12px; }
.label-cell { min-width: 240px; overflow-wrap: anywhere; }
.amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
select.to-check { border-color: #b07400; background: var(--warn-soft); }
tr.duplicate td { background: #fafafa; color: var(--muted); }
.positive { color: var(--good); }
.negative { color: var(--danger); }
.pagination { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }

/* Classement en masse */
.bulk summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.bulk[hidden] { display: none; }
.bulk-row { display: grid; grid-template-columns: minmax(160px, 1.3fr) minmax(140px, 1fr) minmax(140px, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bulk-name { font-weight: 600; overflow-wrap: anywhere; }
.bulk-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) { .bulk-row { grid-template-columns: 1fr 1fr; } .bulk-name { grid-column: 1 / -1; } }

/* File de validation et éléments cliquables */
.review-row { display: grid; grid-template-columns: minmax(200px, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.review-row .actions { grid-column: 1 / -1; }
.review-row .actions select { max-width: 260px; }
select.probable { border-color: #b07400; border-style: dashed; }
.cliquable { cursor: pointer; }
.hbar.cliquable:hover .hbar-label, .hbar.cliquable:focus-visible .hbar-label { text-decoration: underline; }
.hbar.cliquable:focus-visible, .chart rect.cliquable:focus-visible { outline: 3px solid #4fa89c; outline-offset: 2px; }
.chart rect.cliquable:hover { opacity: .75; }

/* Comptes */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 14px; }
.account { margin: 0; display: grid; gap: 10px; align-content: start; }
.account-head { display: flex; align-items: center; gap: 8px; }
.account-name { font-weight: 700; flex: 1; min-width: 0; }
.account label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.account dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.account dt { color: var(--muted); }
.account dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.account dd.big { font-size: 20px; font-weight: 700; }
.card-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.card-num { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Analyses */
.anomalies { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
.anomaly { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-left: 4px solid #7b8790; border-radius: 8px; }
.anomaly.attention { border-left-color: #b07400; }
.anomaly small { color: var(--muted); }

/* Import */
.drop-zone { display: grid; gap: 4px; place-items: center; text-align: center; padding: 34px 16px; border: 2px dashed #8fb8b0; border-radius: 14px; background: #fff; cursor: pointer; }
.drop-zone.over { background: var(--accent-soft); border-color: var(--accent); }
.drop-zone strong { font-size: 16px; color: var(--accent); }
.checks { color: var(--muted); padding-left: 20px; }
.result { border: 1px solid var(--line); border-left: 4px solid var(--good); background: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.result.erreur { border-left-color: var(--danger); }
.result h3 { margin: 0 0 6px; font-size: 15px; }
.result ul { margin: 6px 0 0; padding-left: 18px; }
label.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }

/* Réglages */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

footer { text-align: center; padding: 18px clamp(12px, 4vw, 48px) 26px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
footer p { max-width: 900px; margin: 0 auto; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) {
  body { font-size: 15px; }
  .kpis { grid-template-columns: 1fr; gap: 8px; }
  .kpi strong { font-size: 22px; }
  .brand .wordmark { height: 42px; }
  .privacy { display: none; }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
  /* Version mobile légère : l'essentiel d'abord (chiffres clés, graphique), les panneaux de détail en dessous. */
  .kpi small { display: none; }
  .kpi { padding: 10px 12px; }
  .grid-2 > .card:nth-child(2) .upcoming li:nth-child(n+4) { display: none; }
  .cmp-row { grid-template-columns: 48px minmax(60px, 1fr) auto; }
  .hbar { grid-template-columns: 1fr auto; }
  .hbar-track { grid-column: 1 / -1; grid-row: 2; }
  .anomaly { grid-template-columns: 1fr; }
  .card-row { grid-template-columns: 1fr; }
  .filters select, .filters button { flex: 1 1 140px; }
  .section-heading .actions { width: 100%; }
}

.compact-list { margin: 6px 0; padding-left: 18px; font-size: 13px; display: grid; gap: 2px; }
