/* AFMPro IMPACT — interface */
:root {
  --green: #077A04; --green-d: #04520A; --green-dd: #033d07; --green-l: #e8f3e6; --gold: #D2CA00; --gold-l: #fbf8d6;
  --grey: #9F9D9D; --ink: #1b261d; --muted: #5f6b61; --line: #dfe5dc; --bg: #f4f6f2; --card: #ffffff;
  --blue: #1f5fa8; --red: #b3261e; --red-l: #fdecea; --orange: #a35a00; --orange-l: #fff1dd;
  --radius: 12px; --shadow: 0 1px 2px rgba(10,40,10,.06), 0 4px 14px rgba(10,40,10,.06);
  --font: "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
.ar { direction: rtl; font-family: "Noto Naskh Arabic", "Segoe UI", Arial, sans-serif; }

/* Mise en page */
.layout { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--green-d), var(--green-dd)); color: #fff; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: #fff; display: grid; place-items: center; overflow: hidden; border-bottom: 3px solid var(--gold); }
.brand-mark img { width: 36px; height: 36px; object-fit: contain; }
.brand b { display: block; font-size: 16px; letter-spacing: .3px; }
.brand small { color: rgba(255,255,255,.7); font-size: 11.5px; }
.nav a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.86); text-decoration: none; padding: 9px 10px; border-radius: 9px; margin: 1px 0; font-size: 14.2px; transition: background .15s; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .ic { width: 20px; text-align: center; opacity: .95; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.45); margin: 14px 10px 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; color: var(--green-d); font-weight: 650; }
.menu-btn { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.bell { position: relative; background: none; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; cursor: pointer; }
.bell .dot { position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; }
.content { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }

/* Composants */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; border: 1px solid #edf1eb; }
.card h2 { margin: 0 0 12px; font-size: 16.5px; color: var(--green-d); display: flex; align-items: center; gap: 8px; }
.card h3 { margin: 14px 0 8px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.kpi { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid #edf1eb; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--green); }
.kpi.gold::after { background: var(--gold); } .kpi.red::after { background: var(--red); } .kpi.blue::after { background: var(--blue); }
.kpi .v { font-size: 26px; font-weight: 750; color: var(--green-d); }
.kpi .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--green); background: var(--green); color: #fff; border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; text-decoration: none; font-size: 14px; transition: transform .05s, background .15s; }
.btn:hover { background: var(--green-d); }
.btn:active { transform: translateY(1px); }
.btn.sec { background: #fff; color: var(--green-d); border-color: var(--line); }
.btn.sec:hover { background: var(--green-l); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.red { background: var(--red); border-color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.wa { background: #1f9d55; border-color: #1f9d55; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--line); padding: 8px; }
table.t td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
table.t tr:hover td { background: #fafcf9; }
table.t tr.click { cursor: pointer; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.badge { display: inline-block; border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: #eef0ec; color: #444; white-space: nowrap; }
.b-green { background: #e2f4df; color: #056b03; } .b-gold { background: var(--gold-l); color: #6d6400; } .b-red { background: var(--red-l); color: var(--red); }
.b-orange { background: var(--orange-l); color: var(--orange); } .b-blue { background: #e4eefb; color: var(--blue); } .b-grey { background: #eef0ec; color: #555; }
.alert { border-radius: 10px; padding: 11px 14px; margin: 10px 0; border: 1px solid; font-size: 14px; }
.alert.warn { background: var(--orange-l); border-color: #f1d3a6; color: #6a3c00; }
.alert.err { background: var(--red-l); border-color: #f3c3be; color: #7c1913; }
.alert.ok { background: #e7f5e4; border-color: #bfe0b8; color: #0b5208; }
.alert.info { background: #eef4fb; border-color: #cfdff1; color: #18406f; }
form .f, .f { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.f label { font-size: 13px; font-weight: 600; color: #36423a; }
.f .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=number], input[type=tel], input[type=search], select, textarea {
  border: 1px solid #cfd8cc; border-radius: 9px; padding: 9px 11px; background: #fff; width: 100%; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(7,122,4,.25); border-color: var(--green); }
textarea { min-height: 90px; resize: vertical; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.active { color: var(--green-d); border-color: var(--gold); }
.steps { display: flex; gap: 0; margin: 6px 0 14px; flex-wrap: wrap; }
.steps div { flex: 1; min-width: 120px; padding: 8px 10px; border-top: 4px solid var(--line); font-size: 13px; color: var(--muted); }
.steps div.done { border-color: var(--green); color: var(--green-d); }
.steps div.cur { border-color: var(--gold); color: var(--ink); font-weight: 650; }
.empty { text-align: center; padding: 30px; color: var(--muted); }
.avatar { width: 40px; height: 48px; border-radius: 7px; object-fit: cover; background: #e7ece5; display: inline-grid; place-items: center; color: var(--grey); font-size: 11px; flex: none; }
.avatar.lg { width: 110px; height: 134px; }

/* Grille d'évaluation */
.scale { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.scale button { border: 0; background: #fff; padding: 7px 0; width: 38px; cursor: pointer; font-weight: 700; color: #555; border-right: 1px solid var(--line); }
.scale button:last-child { border-right: 0; }
.scale button.on[data-v="0"] { background: #e9ebe7; color: #333; }
.scale button.on[data-v="1"] { background: #f9d9d6; color: #8c1d16; }
.scale button.on[data-v="2"] { background: #fbe9c8; color: #7a4a00; }
.scale button.on[data-v="3"] { background: #d7efd2; color: #0a5c07; }
.scale button.on[data-v="4"] { background: var(--green); color: #fff; }
.evcard { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: #fff; }
.evcard.complete { border-color: #bfe0b8; background: #fbfef9; }
.evcard .head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.evrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px dashed #edf0eb; }
.evrow .lbl { flex: 1; min-width: 0; font-size: 14px; }
.evrow .lbl small { display: block; color: var(--muted); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12.5px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,242,.96); backdrop-filter: blur(4px); padding: 10px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }

/* Graphiques */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--green), var(--green-d)); border-radius: 6px 6px 2px 2px; transition: height .6s ease; }
.bars .bv { font-size: 12px; font-weight: 700; color: var(--green-d); }
.bars .bl { font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.meter { height: 9px; border-radius: 9px; background: #e8ece6; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--green); border-radius: 9px; transition: width .6s; }
.stack { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: #eee; }
.stack > i { display: block; height: 100%; }

/* Modale */
.modal-back { position: fixed; inset: 0; background: rgba(12,30,12,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; z-index: 100; overflow-y: auto; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 680px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .18s ease-out; }
.modal h2 { margin: 0 0 14px; color: var(--green-d); font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0 } }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: pop .2s; max-width: 92vw; }
.toast.ok { background: var(--green-d); } .toast.err { background: var(--red); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.loading::before { content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 10px; border: 3px solid var(--green-l); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i { position: absolute; top: -10px; width: 8px; height: 14px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .8 } }

/* Connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #0a8f06 0%, transparent 60%), linear-gradient(160deg, var(--green-d), var(--green-dd)); }
.auth .box { background: #fff; border-radius: 18px; padding: 28px; width: 100%; max-width: 410px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth .logo b { font-size: 22px; color: var(--green-d); display: block; }
.auth .logo small { color: var(--muted); }
.auth .goldline { height: 4px; width: 60px; background: var(--gold); border-radius: 3px; margin: -6px 0 18px; }

.lib-svg svg { width: 100%; max-width: 520px; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.prose p { margin: 6px 0; } .prose ul, .prose ol { margin: 6px 0 6px 20px; padding: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 10px 0 40px rgba(0,0,0,.3); }
  .menu-btn { display: block; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .content { padding: 16px 16px 60px; }
  .topbar { padding: 10px 16px; }
  .userbox .who { display: none; }
}
@media (max-width: 640px) {
  .g2, .g3, .g4, .fgrid { grid-template-columns: 1fr; }
  .kpi .v { font-size: 22px; }
  table.t.resp thead { display: none; }
  table.t.resp tr { display: block; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
  table.t.resp td { display: flex; justify-content: space-between; gap: 10px; border: 0; border-bottom: 1px solid #f0f2ee; }
  table.t.resp td::before { content: attr(data-l); font-weight: 600; color: var(--muted); font-size: 12.5px; }
  .scale button { width: 34px; }
  .evrow { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .topbar, .btn, .chips, .sticky-actions { display: none !important; }
  .layout { display: block; } .content { padding: 0; max-width: none; } .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
