:root {
  --brand: #2b8fb3;
  --brand-strong: #1d6f8e;
  --brand-soft: #e6f3f8;
  --ink: #1d2733;
  --ink-2: #4a5768;
  --ink-3: #7b8796;
  --line: #e3e8ee;
  --line-strong: #cfd7e0;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --side: #17323f;
  --side-ink: #c9dbe3;
  --side-active: #24495a;
  --ok: #1f8a5b;
  --ok-soft: #e4f4ec;
  --warn: #b26a00;
  --warn-soft: #fdf1dc;
  --bad: #c0392b;
  --bad-soft: #fbe7e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.brand-name { font-weight: 650; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--side-ink); opacity: .8; }
.nav { padding: 6px 10px 20px; flex: 1; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #8fb0bf; padding: 16px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--side-ink); font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav a.sub { padding-left: 38px; font-size: 13px; }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .soon { margin-left: auto; font-size: 10px; background: rgba(255,255,255,.12); padding: 1px 6px; border-radius: 99px; }
.side-foot { padding: 12px 18px 16px; font-size: 11px; color: #8fb0bf; border-top: 1px solid rgba(255,255,255,.08); }

.main { display: flex; flex-direction: column; min-width: 0; }
.top { height: 60px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.search { flex: 1; max-width: 520px; position: relative; }
.search input[type=search] { width: 100%; height: 36px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 0 12px 0 34px; font: inherit; }
.search input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); background: #fff; }
.search svg { position: absolute; left: 10px; top: 9px; width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; }
.suggestions { position: absolute; top: 42px; left: 0; right: 0; min-width: 360px; max-height: min(70vh, 560px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 40, .16); padding: 6px; z-index: 30; }
.sg-groupe { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 10px 10px 4px; }
.sg-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--ink); }
.sg-item:hover, .sg-item.on { background: var(--brand-soft); text-decoration: none; }
.sg-item .avatar { width: 28px; height: 28px; font-size: 11px; }
.sg-textes { display: flex; flex-direction: column; min-width: 0; }
.sg-titre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-titre b { color: var(--brand-strong); }
.sg-detail { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-vide { padding: 12px 10px; color: var(--ink-3); }
.sg-tout { display: block; margin-top: 4px; padding: 9px 10px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 550; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me-name { text-align: right; line-height: 1.15; }
.me-name small { color: var(--ink-3); display: block; font-size: 11.5px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.content { padding: 24px 28px 48px; max-width: 1360px; width: 100%; }
.top .menu-btn { display: none; }

/* ---------- En-têtes de page ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Boutons & formulaires ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--bad); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
form.inline { display: inline; }
.btn.confirm-arme { background: var(--bad); border-color: var(--bad); color: #fff; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 38px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; font: inherit; color: var(--ink); background: #fff;
}
textarea { height: auto; min-height: 90px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=file] { font: inherit; }
label.check { display: flex; align-items: center; gap: 6px; height: 38px; margin: 0; font-weight: 550; white-space: nowrap; }
.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)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row-form > div { flex: 1; min-width: 150px; }
.row-form > div.narrow { flex: 0 0 auto; min-width: 0; }

/* ---------- Cartes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: inherit; display: block; }
.kpi:hover { text-decoration: none; border-color: var(--line-strong); }
.kpi-label { font-size: 12px; color: var(--ink-2); }
.kpi-value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.alert .kpi-value { color: var(--warn); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.person-cell { display: flex; align-items: center; gap: 10px; }
.person-cell .avatar { width: 30px; height: 30px; font-size: 11.5px; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #eef1f4; color: var(--ink-2); white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-brand { background: var(--brand-soft); color: var(--brand-strong); }
.b-teal { background: #e0f2f1; color: #00695c; }
.b-blue { background: #e3f0fc; color: #1565c0; }
.b-indigo { background: #e8eaf6; color: #3949ab; }
.b-violet { background: #f1e8fb; color: #7b3fb5; }
.b-amber { background: #fff4d6; color: #9a6400; }
.b-rose { background: #fde8ef; color: #ad1457; }
.b-green { background: #e6f4e7; color: #2e7d32; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

/* ---------- Filtres & onglets ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font-weight: 550; font-size: 13px; }
.chip:hover { text-decoration: none; border-color: var(--brand); color: var(--brand-strong); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: 11px; opacity: .75; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; flex: 1; max-width: 640px; }
.toolbar input, .toolbar select { height: 34px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--brand-strong); border-color: var(--brand); }
.tabs .n { font-size: 11px; background: #eef1f4; border-radius: 99px; padding: 1px 7px; margin-left: 4px; color: var(--ink-2); }

/* ---------- Fiche ---------- */
.hero { display: flex; gap: 16px; align-items: center; }
.hero h1 { font-size: 24px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--ink-3); font-size: 13px; }
.dl dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: var(--line-strong); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12px; color: var(--ink-3); }

.parcours { display: flex; flex-direction: column; gap: 10px; }
.etape { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.etape.finie { opacity: .65; }
.etape .periode { font-size: 12.5px; color: var(--ink-3); }

.progress { height: 8px; background: #eef1f4; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.progress.mid > span { background: #e0a100; }
.progress.low > span { background: var(--bad); }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.ck { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.ck.ok { background: var(--ok-soft); color: var(--ok); }
.ck.ko { background: var(--bad-soft); color: var(--bad); }
.ck.mid { background: var(--warn-soft); color: var(--warn); }

.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; font-weight: 550; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.note { background: var(--brand-soft); color: var(--brand-strong); border-radius: 8px; padding: 10px 14px; font-size: 13px; }

.toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.toggle label { margin: 0; }
.toggle input { display: none; }
.toggle span { display: inline-block; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.toggle input:checked + span.p { background: var(--ok-soft); color: var(--ok); }
.toggle input:checked + span.a { background: var(--bad-soft); color: var(--bad); }

/* ---------- Calendrier ---------- */
.cal-titre { text-transform: capitalize; }
.calendrier { overflow: hidden; margin-bottom: 20px; }
.cal-grille { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-entete { padding: 8px 10px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; color: var(--ink-3); background: #fafbfc; border-bottom: 1px solid var(--line); }
.cal-jour { min-height: 108px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-jour:nth-child(7n + 7) { border-right: 0; }
.cal-jour.hors { background: #fafbfc; }
.cal-jour.hors .cal-num { color: var(--line-strong); }
.cal-num { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.cal-jour.auj .cal-num { background: var(--brand); color: #fff; border-radius: 99px; width: 24px; height: 24px; display: grid; place-items: center; }
.cal-evt { display: block; font-size: 11.5px; line-height: 1.3; padding: 3px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.cal-evt:hover { text-decoration: none; filter: brightness(.95); }
.cal-creneau { opacity: .75; font-weight: 500; }
.cal-liste { display: none; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: var(--side); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h2 { font-size: 26px; line-height: 1.25; max-width: 420px; font-weight: 600; }
.login-side p { color: var(--side-ink); max-width: 420px; }
.login-main { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { margin-bottom: 6px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; justify-content: center; height: 42px; }
.erreur { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-weight: 550; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .top .menu-btn { display: inline-flex; }
  .suggestions { position: fixed; top: 58px; left: 8px; right: 8px; min-width: 0; }
  .top { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  .me-name { display: none; }
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .calendrier { display: none; }
  .cal-liste { display: block; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
