:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1b2733;
  --ink-2: #4a5866;
  --ink-3: #7a8692;
  --line: #e2ddd3;
  --line-2: #cfc8bb;
  --primary: #16324a;
  --primary-2: #24577a;
  --accent: #b5731c;
  --accent-soft: #f6ead6;
  --ok: #2f7a4f;
  --ok-soft: #e3f1e8;
  --warn: #9a6500;
  --warn-soft: #fbf0d9;
  --bad: #b23a2e;
  --bad-soft: #f8e3e0;
  --l0: #e9e4da;
  --l1: #cfe0ea;
  --l2: #9cc2d6;
  --l3: #5b95b6;
  --l4: #24577a;
  --target: #b5731c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 50, 74, .06), 0 2px 8px rgba(22, 50, 74, .05);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.5rem, 3vw, 2rem); color: var(--primary); }
h2 { font-size: 1.2rem; color: var(--primary); }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 0; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem max(16px, calc((100% - 1180px) / 2));
  background: var(--primary); color: #fff;
}
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-mark {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem; letter-spacing: .02em;
}
.brand-title { font-weight: 600; font-size: 1.02rem; }
.brand-sub { font-size: .8rem; opacity: .8; }
.save-status { font-size: .8rem; opacity: .85; text-align: right; white-space: nowrap; }

/* Steps */
.steps {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: thin;
  padding: .5rem max(16px, calc((100% - 1180px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.step {
  flex: none; display: flex; align-items: center; gap: .5rem;
  padding: .45rem .75rem; border-radius: 999px; border: 1px solid transparent;
  text-decoration: none; color: var(--ink-2); font-size: .9rem; white-space: nowrap;
}
.step:hover { background: var(--surface-2); }
.step[aria-current="page"] { background: var(--primary); color: #fff; }
.step .num {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--l0); color: var(--ink-2); font-size: .75rem; font-weight: 700;
}
.step[aria-current="page"] .num { background: #fff; color: var(--primary); }
.step.done .num { background: var(--ok); color: #fff; }
.step .meta { font-size: .75rem; opacity: .75; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 16px 3rem; outline: none; }
.foot { max-width: 1180px; margin: 0 auto; padding: 1rem 16px 2rem; color: var(--ink-3); font-size: .8rem; border-top: 1px solid var(--line); }

/* Generic */
.lead { font-size: 1.05rem; color: var(--ink-2); max-width: 70ch; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.spacer { flex: 1; }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-head p { margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: .45rem; justify-content: center;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; font-size: .95rem;
}
.btn:hover { border-color: var(--primary-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary-2); }
.btn.danger { color: var(--bad); border-color: #e7c2bd; }
.btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field .hint { display: block; font-weight: 400; color: var(--ink-3); font-size: .8rem; margin-top: .25rem; }
input[type="text"], input[type="date"], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line-2); border-radius: 8px;
  background: #fffdf7; transition: border-color .15s;
}
textarea { min-height: 2.6rem; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); outline: none; box-shadow: 0 0 0 3px rgba(36, 87, 122, .15); }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--l0); color: var(--ink-2); white-space: nowrap;
}
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.info { background: #e4edf3; color: var(--primary-2); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

.note { padding: .75rem 1rem; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--line-2); font-size: .92rem; }
.note.warn { background: var(--warn-soft); border-color: var(--warn); }
.note.bad { background: var(--bad-soft); border-color: var(--bad); }
.note.ok { background: var(--ok-soft); border-color: var(--ok); }
.note.info { background: #e9f0f5; border-color: var(--primary-2); }
.note p:last-child, .note ul:last-child { margin-bottom: 0; }
.msgs { display: flex; flex-direction: column; gap: .35rem; margin-top: .6rem; }
.msg { font-size: .85rem; padding: .35rem .6rem; border-radius: 6px; }
.msg.warn { background: var(--warn-soft); color: #6e4800; }
.msg.bad { background: var(--bad-soft); color: var(--bad); }
.msg.info { background: #e9f0f5; color: var(--primary-2); }

.progress { height: 8px; border-radius: 999px; background: var(--l0); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .3s; }

/* Home */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.howto { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.howto li { counter-increment: s; position: relative; padding: .55rem 0 .55rem 2.6rem; border-bottom: 1px dashed var(--line); }
.howto li:last-child { border-bottom: 0; }
.howto li::before {
  content: counter(s); position: absolute; left: 0; top: .55rem; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .85rem;
}
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.scale div { padding: .5rem; border-radius: 8px; font-size: .8rem; }
.scale b { display: block; font-size: 1.1rem; }
@media (max-width: 600px) { .scale { grid-template-columns: 1fr; } .scale b { display: inline; margin-right: .4rem; } }
.lv0 { background: var(--l0); } .lv1 { background: var(--l1); } .lv2 { background: var(--l2); }
.lv3 { background: var(--l3); color: #fff; } .lv4 { background: var(--l4); color: #fff; }
ul.rules { margin: 0; padding-left: 1.2rem; }
ul.rules li { margin-bottom: .35rem; }

/* Grille */
.dimtabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.dimtab {
  flex: 1 1 180px; text-align: left; padding: .65rem .85rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.dimtab[aria-pressed="true"] { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: #eef3f7; }
.dimtab .t { font-weight: 600; display: block; }
.dimtab .s { font-size: .8rem; color: var(--ink-3); }
.dimtab .progress { margin-top: .4rem; height: 5px; }

.crit { padding: 0; overflow: hidden; }
.crit + .crit { margin-top: 1rem; }
.crit-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.code { font-weight: 700; color: #fff; background: var(--primary); border-radius: 6px; padding: .1rem .5rem; font-size: .85rem; }
.crit-head h3 { margin: 0; font-size: 1.02rem; }
.crit-body { padding: 1rem 1.25rem 1.25rem; }
.lbl { font-weight: 600; font-size: .85rem; color: var(--ink-2); margin: 0 0 .4rem; display: block; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
@media (max-width: 760px) { .levels { grid-template-columns: 1fr; } }
.level {
  position: relative; text-align: left; padding: .55rem .6rem .6rem; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); font-size: .82rem; line-height: 1.35; min-height: 100%;
}
.level:hover { border-color: var(--l3); }
.level .n { display: flex; align-items: baseline; gap: .35rem; font-weight: 700; font-size: .78rem; color: var(--ink-2); margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .02em; }
.level .n b { font-size: 1.05rem; color: var(--primary); }
.level[aria-pressed="true"] { border-color: var(--primary); background: #e8f0f6; box-shadow: inset 0 0 0 1px var(--primary); }
.level.is-target::after {
  content: "Cible"; position: absolute; top: .4rem; right: .45rem; font-size: .65rem; font-weight: 700;
  background: var(--target); color: #fff; padding: .05rem .35rem; border-radius: 4px;
}
.crit-cols { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; margin-top: 1rem; }
@media (max-width: 760px) { .crit-cols { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: .45rem .75rem; cursor: pointer; min-width: 2.4rem; font-weight: 600; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--target); color: #fff; }
.seg.score button[aria-pressed="true"] { background: var(--primary); }
.seg button.below { color: var(--ink-3); background: repeating-linear-gradient(135deg, transparent 0 4px, #f1ede4 4px 7px); }
.gapline { margin-top: .5rem; font-size: .85rem; color: var(--ink-2); }
details.more summary { cursor: pointer; color: var(--primary-2); font-size: .85rem; margin-top: .75rem; }
.navbtns { display: flex; justify-content: space-between; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* Synthèse */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .v { font-size: 1.7rem; font-weight: 700; color: var(--primary); line-height: 1.1; }
.kpi .v small { font-size: .9rem; font-weight: 500; color: var(--ink-3); }
.kpi .k { font-size: .8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kpi.alert .v { color: var(--bad); }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th, table.t td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); }
.table-wrap { overflow-x: auto; }
.radar-wrap { display: flex; justify-content: center; }
.radar-wrap svg { width: 100%; max-width: 480px; height: auto; }
.legend { display: flex; gap: 1rem; justify-content: center; font-size: .85rem; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: .35rem; }
.strip { display: grid; grid-template-columns: 52px 1fr 70px; gap: .35rem .6rem; align-items: center; font-size: .85rem; }
.strip .bar { position: relative; height: 12px; background: var(--l0); border-radius: 6px; }
.strip .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--l3); border-radius: 6px; }
.strip .bar b { position: absolute; top: -3px; width: 3px; height: 18px; background: var(--target); border-radius: 2px; }
.strip .lab { font-weight: 600; }
.strip .val { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.strip .dimrow { grid-column: 1 / -1; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-top: .4rem; }
.suggest { display: flex; flex-wrap: wrap; gap: .35rem; margin: .25rem 0 .6rem; }
.suggest button { border: 1px dashed var(--line-2); background: var(--surface-2); border-radius: 999px; padding: .2rem .6rem; font-size: .8rem; cursor: pointer; color: var(--ink-2); }
.suggest button:hover { border-color: var(--primary-2); color: var(--primary-2); }
.numbered { display: grid; grid-template-columns: 1.6rem 1fr; gap: .5rem; align-items: start; }
.numbered + .numbered { margin-top: .5rem; }
.numbered > b { padding-top: .55rem; color: var(--accent); }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { display: flex; gap: .6rem; align-items: flex-start; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.checks li:last-child { border-bottom: 0; }
.checks .ic { flex: none; width: 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: #fff; }
.ic.ok { background: var(--ok); } .ic.bad { background: var(--bad); } .ic.warn { background: var(--warn); } .ic.todo { background: var(--line-2); }

/* Priorisation */
.gaps { display: flex; flex-wrap: wrap; gap: .5rem; }
.gapcard {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem .4rem .7rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); font-size: .85rem;
}
.gapcard.weak { border-color: #e7b7b0; background: var(--bad-soft); }
.action { padding: 0; overflow: hidden; }
.action + .action { margin-top: 1rem; }
.action-head { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.action-head .aid { flex: none; font-weight: 700; color: var(--accent); font-size: 1.05rem; padding-top: .45rem; min-width: 2.2rem; }
.action-head textarea { font-weight: 600; }
.action-body { padding: 1rem 1.25rem 1.25rem; }
.codes { display: flex; flex-wrap: wrap; gap: .3rem; }
.codes button {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 6px; padding: .2rem .45rem;
  font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--ink-2);
}
.codes button.has-gap { border-color: var(--l3); }
.codes button.weak { border-color: var(--bad); color: var(--bad); }
.codes button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1rem; }
@media (max-width: 860px) { .scores { grid-template-columns: 1fr; } }
.scorebox h4 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); display: flex; justify-content: space-between; align-items: baseline; }
.scorebox h4 .avg { font-size: 1.2rem; color: var(--primary); text-transform: none; letter-spacing: 0; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.srow:last-child { border-bottom: 0; }
.srow .sl { font-size: .88rem; }
.srow .sl small { display: block; color: var(--ink-3); font-size: .75rem; }
.seg.score button { min-width: 2rem; padding: .3rem .5rem; }
@media (max-width: 600px) {
  .srow { flex-direction: column; align-items: stretch; gap: .3rem; }
  .srow .seg { display: flex; }
  .srow .seg button { flex: 1; padding: .45rem 0; }
  .action-head, .action-body, .crit-body, .crit-head { padding-left: .9rem; padding-right: .9rem; }
  .card { padding: 1rem; }
}
.action-foot { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.prio button[aria-pressed="true"] { background: var(--accent); }
.quad { font-weight: 700; }
.q-gr { color: var(--ok); } .q-ps { color: var(--primary-2); } .q-ap { color: var(--warn); } .q-rep { color: var(--ink-3); }
.matrix svg { width: 100%; height: auto; max-width: 560px; display: block; margin: 0 auto; }
.sticky-side { position: sticky; top: 64px; }
.prio-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.25rem; align-items: start; }
@media (max-width: 1040px) { .prio-layout { grid-template-columns: 1fr; } .sticky-side { position: static; } }

/* Fiches */
.fiche { border-top: 4px solid var(--accent); }
.fiche .ftitle { font-size: 1.05rem; font-weight: 600; margin-bottom: .25rem; }
.fiche .fields { display: grid; gap: .85rem; margin-top: 1rem; }

/* Export */
.export-main { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.export-main .card h3 { margin-bottom: .35rem; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(150%);
  background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: .9rem;
  transition: transform .25s; z-index: 20; max-width: calc(100% - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* Print */
#print { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 10.5pt; }
  body > *:not(#print) { display: none !important; }
  #print { display: block !important; }
  .pr h1 { font-size: 15pt; margin-bottom: 2pt; }
  .pr h2 { font-size: 11.5pt; margin: 8pt 0 4pt; border-bottom: 1px solid #999; padding-bottom: 2pt; }
  .pr .meta { font-size: 9pt; color: #444; margin-bottom: 6pt; }
  .pr .cols { display: grid; grid-template-columns: 1fr 250px; gap: 10pt; align-items: start; }
  .pr table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  .pr th, .pr td { border: 1px solid #bbb; padding: 3pt 5pt; text-align: left; vertical-align: top; }
  .pr td.num, .pr th.num { text-align: right; }
  .pr ol { margin: 0; padding-left: 14pt; }
  .pr .fiche-p { page-break-inside: avoid; margin-bottom: 10pt; }
  .pr .fiche-p th { width: 34%; background: #f3f3f3; }
  .pr .brk { page-break-before: always; }
  .pr svg { width: 250px; height: auto; }
}
