:root {
  --ink: #14161a;
  --ink-2: #3b3f47;
  --muted: #6b707a;
  --line: #e4e2dc;
  --bg: #f6f5f1;
  --card: #ffffff;
  --accent: #c8f169;
  --accent-ink: #2f4a00;
  --good: #0d7a4c;
  --mid: #a86500;
  --bad: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 4px 16px rgba(20, 22, 26, .04);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* --- mise en page ------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: #e9eae6; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 10px 18px; }
.brand-dot { width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--accent); display: grid; place-items: center; }
.brand-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.nav a {
  display: flex; justify-content: space-between; align-items: center; text-decoration: none; padding: 9px 10px;
  border-radius: 8px; color: #c9cbc5; font-size: 14.5px;
}
.nav a:hover { background: #22252b; color: #fff; }
.nav a.active { background: #2a2e35; color: #fff; }
.nav .count { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.nav .count.zero { background: #2f333a; color: #9a9d97; }
.side-foot { margin-top: auto; display: grid; gap: 6px; padding: 0 4px; }
.main { padding: 28px 34px 60px; max-width: 1280px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.stack { display: grid; gap: 14px; }

/* --- éléments ------------------------------------------------------------ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px;
  padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: #c9c6bd; background: #fbfaf7; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2a2e35; }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: #b5dc55; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.side .btn { background: #22252b; color: #e9eae6; border-color: #2f333a; justify-content: center; }
.side .btn:hover { background: #2a2e35; }
.side .btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn[disabled] { opacity: .55; cursor: progress; }
input, select, textarea {
  font: inherit; font-size: 14.5px; color: var(--ink); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; width: 100%; font-weight: 400;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #9ccc2b; outline-offset: 1px; border-color: #9ccc2b; }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
label { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
label .hint { font-weight: 400; color: var(--muted); }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 160px; }
.filters input[type=search] { flex: 1; min-width: 200px; }

.badge { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 9px; border-radius: 99px; background: #eeece6; color: var(--ink-2); white-space: nowrap; }
.badge.todo { background: #eaf7cf; color: var(--accent-ink); }
.badge.sent { background: #e2ecfb; color: #1f4f9c; }
.badge.replied { background: #fdf0d8; color: #8a5300; }
.badge.won { background: #d6f2e3; color: var(--good); }
.badge.lost, .badge.error { background: #fbe4e2; color: var(--bad); }
.badge.pending { background: #efeaf9; color: #5b3fa3; }
.score {
  min-width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; font-size: 17px;
  background: #eeece6; color: var(--ink-2); flex: none;
}
.score.hi { background: #e3f5c4; color: var(--accent-ink); }
.score.md { background: #fdf0d8; color: var(--mid); }
.score.lo { background: #f1efea; color: #9a9d97; }

.list { display: grid; gap: 8px; }
.item {
  display: flex; gap: 14px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; text-decoration: none; transition: border-color .12s, transform .12s;
}
.item:hover { border-color: #c9c6bd; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.item .summary { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
.desc { white-space: pre-wrap; font-size: 14px; color: var(--ink-2); max-height: 520px; overflow: auto; overflow-wrap: anywhere; }
.points { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.points li { margin: 2px 0; }
.draft { min-height: 360px; font-size: 15px; }
.status-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.status-bar .btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.bars div { flex: 1; background: #e4e2dc; border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.bars div span { position: absolute; bottom: 0; left: 0; right: 0; background: #9ccc2b; border-radius: 3px 3px 0 0; }

.feature { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feature:last-child { border-bottom: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; background: #c9c6bd; }
.dot.on { background: #4caf50; }
.dot.err { background: var(--bad); }
.log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; max-height: 420px; overflow: auto; }
.log div { padding: 4px 0; border-bottom: 1px solid #f0eee8; overflow-wrap: anywhere; }
.log .error { color: var(--bad); }
.log .warn { color: var(--mid); }
code { background: #eeece6; padding: 1px 6px; border-radius: 5px; font-size: 13px; overflow-wrap: anywhere; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login form { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 30px; display: grid; gap: 16px; }
.err-msg { color: var(--bad); font-size: 14px; }

.modal-back { position: fixed; inset: 0; background: rgba(20, 22, 26, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: min(640px, 100%); max-height: 92vh; overflow: auto; display: grid; gap: 14px; }

#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }

.topbar { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0; z-index: 40; height: 100vh; }
  .side.open { display: flex; }
  .topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar .btn { background: #22252b; color: #fff; border-color: #2f333a; }
  .main { padding: 18px 14px 50px; }
  .detail, .grid2 { grid-template-columns: 1fr; }
  .filters select, .filters input { min-width: 0; flex: 1 1 140px; }
  h1 { font-size: 22px; }
}
