:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --bg-hover: #f1f1f3;
  --line: #e8e8ec;
  --text: #1c1c21;
  --text-2: #5e5e6b;
  --text-3: #9393a0;
  --accent: #5b5bd6;
  --accent-soft: #eeeefc;
  --red: #d9475a;
  --red-soft: #fdecee;
  --amber: #b7791f;
  --amber-soft: #fdf4e3;
  --green: #2f9e6a;
  --green-soft: #e6f6ee;
  --blue: #2f7ad9;
  --blue-soft: #e8f1fc;
  --gray-soft: #f0f0f3;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 4px 16px rgba(20, 20, 40, .06);
  --radius: 10px;
  --nav-w: 220px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --bg-soft: #1d1d22;
    --bg-hover: #26262c;
    --line: #2d2d34;
    --text: #ececf1;
    --text-2: #a9a9b6;
    --text-3: #72727e;
    --accent: #8b8bf0;
    --accent-soft: #2a2a4a;
    --red: #f07384;
    --red-soft: #3a2026;
    --amber: #e3ad55;
    --amber-soft: #352a17;
    --green: #5cc796;
    --green-soft: #18302a;
    --blue: #6ea8f0;
    --blue-soft: #1a2a3e;
    --gray-soft: #26262c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Connexion */
.login { min-height: 100%; display: grid; place-items: center; background: var(--bg-soft); padding: 16px; }
.login-card { background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow); display: grid; gap: 12px; justify-items: center; }
.login-card h1 { margin: 4px 0 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--text-2); }
.login-card input { width: 100%; }
.error { color: var(--red); min-height: 1.2em; }

/* Structure */
.app { display: flex; height: 100%; }
.nav { width: var(--nav-w); flex: none; background: var(--bg-soft); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; padding: 4px 10px 16px; }
.brand img { width: 26px; height: 26px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--bg-hover); }
.nav a.on { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--text-3); }
.nav .count.hot { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; }
.nav-foot { margin-top: auto; font-size: 12px; color: var(--text-3); padding: 10px; display: grid; gap: 6px; }
.nav-foot button { background: none; border: 0; padding: 0; color: var(--text-3); text-align: left; cursor: pointer; }
.nav-foot button:hover { color: var(--text); }
.main { flex: 1; min-width: 0; overflow: auto; }
.content { max-width: 1240px; margin: 0 auto; padding: 28px 32px 80px; }

/* En-têtes */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 680; letter-spacing: -.01em; }
.page-head .sub { color: var(--text-2); margin-top: 4px; }
.page-head .grow { flex: 1; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
h2 .muted { font-weight: 400; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }

/* Contrôles */
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn svg { width: 15px; height: 15px; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=email], select, textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; resize: vertical; min-height: 70px; }
.search { position: relative; }
.search input { padding-left: 32px; width: 260px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 20px; padding: 4px 11px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.chip:hover { background: var(--bg-hover); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .6; margin-left: 4px; }

/* Pastilles */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 550; background: var(--gray-soft); color: var(--text-2); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.violet { background: var(--accent-soft); color: var(--accent); }
.pill.link { cursor: pointer; }
.pill.link:hover { filter: brightness(.96); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 650; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.sq { border-radius: 8px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }
.star { background: none; border: 0; cursor: pointer; color: var(--text-3); padding: 0 2px; font-size: 15px; line-height: 1; }
.star.on { color: #f0b429; }

/* Tableau */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--bg); }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-weight: 550; font-size: 12px; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--bg-soft); position: sticky; top: 0; white-space: nowrap; cursor: pointer; user-select: none; }
.grid th.sorted { color: var(--text); }
.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--bg-hover); }
.grid .name { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.grid .name span.t { overflow: hidden; text-overflow: ellipsis; }
.more { text-align: center; padding: 14px; }

/* Cartes */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); padding: 16px; }
.card + .card { margin-top: 12px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.stack > * + * { margin-top: 24px; }

/* Recommandations */
.reco { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--bg); display: grid; gap: 10px; }
.reco + .reco { margin-top: 12px; }
.reco-head { display: flex; align-items: center; gap: 12px; }
.reco-head .who { flex: 1; min-width: 0; }
.reco-head .org { font-weight: 650; font-size: 15px; }
.reco-head .person { color: var(--text-2); font-size: 13px; }
.score { font-size: 12px; color: var(--text-3); }
.reasons { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.reasons li { display: flex; gap: 8px; align-items: baseline; color: var(--text-2); }
.reasons li .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; transform: translateY(-1px); background: var(--text-3); }
.reasons li.news .dot { background: var(--blue); }
.reasons li.relance .dot { background: var(--amber); }
.reasons li.retard .dot { background: var(--red); }
.reasons li.echeance .dot { background: var(--accent); }
.reasons a { color: var(--text); }
.reasons a:hover { text-decoration: underline; }
.angle { background: var(--accent-soft); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.angle b { color: var(--accent); font-weight: 600; }
.reco-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--text-3); padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Listes */
.list { display: grid; }
.li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .body { flex: 1; min-width: 0; }
.li .title { font-weight: 520; }
.li .meta { color: var(--text-3); font-size: 12px; margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.li.done .title { text-decoration: line-through; color: var(--text-3); }
.li.clickable { cursor: pointer; }
.li.clickable:hover .title { color: var(--accent); }
.check { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--text-3); background: none; cursor: pointer; flex: none; margin-top: 1px; display: grid; place-items: center; padding: 0; }
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.check svg { width: 12px; height: 12px; }
.late { color: var(--red); font-weight: 550; }
.x { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 2px 4px; border-radius: 4px; opacity: 0; }
.li:hover .x { opacity: 1; }
.x:hover { background: var(--bg-hover); color: var(--text); }

/* Chronologie */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl { position: relative; padding: 0 0 14px; }
.tl::before { content: ""; position: absolute; left: -17px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.tl.app::before { border-color: var(--green); }
.tl .when { font-size: 12px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.tl .what { font-weight: 550; }
.tl .sum { color: var(--text-2); font-size: 13px; }

/* Page organisation */
.org-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.org-head h1 { margin: 0; font-size: 24px; display: flex; align-items: center; gap: 8px; }
.org-head .desc { color: var(--text-2); margin-top: 4px; max-width: 760px; }
.org-head .grow { flex: 1; min-width: 240px; }
.fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { color: var(--text-3); font-size: 13px; display: inline-flex; gap: 4px; margin-bottom: 10px; cursor: pointer; }
.back:hover { color: var(--text); }
.wiki { color: var(--text-2); font-size: 13.5px; }
.wiki h3, .wiki h4 { font-size: 14px; color: var(--text); margin: 14px 0 6px; }
.wiki ul { padding-left: 18px; margin: 6px 0; }
.wiki p { margin: 6px 0; }
.wiki a { color: var(--accent); }
.collapsed { max-height: 180px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.inline-form input[type=text] { flex: 1; min-width: 160px; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv a { color: var(--accent); }
.signal-bar { display: flex; gap: 6px; align-items: center; }
.news-li .title a:hover { text-decoration: underline; }

/* Tiroir contact */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .22s ease; z-index: 30; overflow: auto; padding: 22px; }
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(10, 10, 20, .25); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; }
.drawer-head h2 { font-size: 19px; margin: 0; }
.drawer section { margin-top: 20px; }
.close { margin-left: auto; }

/* Modale */
.modal { position: fixed; inset: 0; background: rgba(10, 10, 20, .35); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 440px; padding: 20px; display: grid; gap: 12px; }
.modal-card h3 { margin: 0; font-size: 16px; }
.modal-card label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.modal-card .row { display: flex; gap: 8px; }
.modal-card .row > * { flex: 1; }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); }

/* Pipeline */
.content.wide { max-width: none; padding-left: 20px; padding-right: 20px; }
.kanban { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.kcol { min-width: 0; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: 120px; transition: background .15s; }
.kcol.over { background: var(--accent-soft); border-color: var(--accent); }
.khead { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; padding: 2px 2px 8px; line-height: 1.2; }
.khead .muted { margin-left: auto; font-weight: 400; }
.kdot { width: 8px; height: 8px; border-radius: 50%; }
.kbody { display: grid; gap: 8px; }
.kcard { min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: grab; display: grid; gap: 7px; box-shadow: 0 1px 2px rgba(20, 20, 40, .04); }
.kcard:hover { border-color: var(--text-3); }
.kcard.dragging { opacity: .4; }
.kname { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; min-width: 0; }
.kname .avatar { width: 24px; height: 24px; font-size: 10px; }
.kname span:not(.avatar):not(.star) { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.kmeta { display: flex; gap: 4px; flex-wrap: wrap; }
.kfoot { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
@media (max-width: 1280px) { .kname .avatar { display: none; } .kmeta .pill { font-size: 11px; padding: 0 6px; } }
.kmove { display: none; font-size: 12px; padding: 3px 6px; }
@media (hover: none) { .kmove { display: block; } .kcard { cursor: pointer; } }

/* Mobile */
@media (max-width: 860px) {
  .app { flex-direction: column-reverse; }
  .nav { width: 100%; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 0; }
  .brand, .nav-foot, .nav .count:not(.hot) { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; position: relative; }
  .kanban { grid-template-columns: 1fr; }
  .nav a.on { box-shadow: none; background: none; color: var(--accent); }
  .nav .count.hot { position: absolute; top: 0; right: 4px; font-size: 10px; padding: 0 5px; }
  .content { padding: calc(16px + env(safe-area-inset-top)) 16px 32px; }
  .cols { grid-template-columns: 1fr; }
  .search input { width: 100%; }
  .search { flex: 1; }
  .hide-m { display: none; }
  .grid td { max-width: 180px; }
  .page-head h1 { font-size: 21px; }
  .x { opacity: 1; }
}
