:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #5f6673;
  --border: #e2e5ea;
  --accent: #2f5bea;
  --accent-soft: #e8eefe;
  --good: #1a7f4b;
  --good-soft: #e3f4ea;
  --warn: #a35d00;
  --warn-soft: #fdf0dc;
  --bad: #c0322b;
  --bad-soft: #fbe6e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --text: #e8eaef; --muted: #9aa2b1;
    --border: #2a2f3a; --accent: #7b9cff; --accent-soft: #1e2a4d; --good: #4fca86; --good-soft: #15301f;
    --warn: #f0a540; --warn-soft: #3a2a12; --bad: #ff6b63; --bad-soft: #3d1817;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --text: #e8eaef; --muted: #9aa2b1;
  --border: #2a2f3a; --accent: #7b9cff; --accent-soft: #1e2a4d; --good: #4fca86; --good-soft: #15301f;
  --warn: #f0a540; --warn-soft: #3a2a12; --bad: #ff6b63; --bad-soft: #3d1817;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px; }
.muted { color: var(--muted); font-size: .85rem; }
button, select, input, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; min-height: 40px;
}
button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button.ghost { white-space: nowrap; background: transparent; color: var(--text); border-color: var(--border); }
button.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 1.15rem; }
.banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px 16px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.kpi .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: .8rem; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select { flex: 0 1 auto; }

.layout { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; padding: 0 16px 32px; align-items: start; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 220px); overflow: auto; position: sticky; top: 76px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; box-shadow: var(--shadow);
}
.card[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card .row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card .name { font-weight: 650; }
.card .meta { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.card .headline { font-size: .85rem; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-height: 300px; }
.detail .back { display: none; margin-bottom: 12px; }
.dhead { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.dhead .sub { color: var(--muted); margin-top: 4px; }
.scores { display: flex; gap: 10px; }
.score { text-align: center; min-width: 74px; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.score .v { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.score.good .v { color: var(--good); } .score.warn .v { color: var(--warn); } .score.bad .v { color: var(--bad); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
.field .k { font-size: .75rem; color: var(--muted); }
.field .v { overflow-wrap: anywhere; }
.call { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 1.05rem; }

.pains { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.pains li { padding: 8px 10px; border-left: 3px solid var(--bad); background: var(--bad-soft); border-radius: 0 8px 8px 0; color: var(--text); }
.pains li.comp { border-color: var(--warn); background: var(--warn-soft); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .75rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.me td { background: var(--accent-soft); font-weight: 600; }
.pos { display: inline-block; min-width: 34px; text-align: center; padding: 1px 6px; border-radius: 6px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pos.p1 { background: var(--good-soft); color: var(--good); }
.pos.p2 { background: var(--warn-soft); color: var(--warn); }
.pos.p3 { background: var(--bad-soft); color: var(--bad); }
.pos.none { color: var(--muted); }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { background: transparent; color: var(--muted); border-color: var(--border); min-height: 34px; padding: 4px 12px; }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; }
.checks li { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; padding: 4px 0; }
.checks .ic { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; }
.checks .ok .ic { background: var(--good-soft); color: var(--good); }
.checks .ko .ic { background: var(--bad-soft); color: var(--bad); }
.checks .na .ic { background: var(--surface-2); color: var(--muted); }
.checks .d { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.w3 .lab::after { content: " ●"; color: var(--bad); font-size: .6rem; vertical-align: middle; }

.track { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 10px; }
.track textarea { min-height: 80px; resize: vertical; width: 100%; }
.pitch { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: var(--radius); font-size: .9rem; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.lock { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 20; padding: 16px; }
.lock[hidden] { display: none; }
.lock-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.remember { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .9rem; }
.remember input { min-height: 0; }
.error { color: var(--bad); margin: 0; }

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .list { max-height: none; position: static; }
  .detail { display: none; }
  body.show-detail .detail { display: block; }
  body.show-detail .list, body.show-detail .filters, body.show-detail .kpis { display: none; }
  .detail .back { display: inline-flex; }
  .grid2, .checks, .track { grid-template-columns: minmax(0, 1fr); }
  .filters select { flex: 1 1 45%; }
}

/* ------------------------------------------------------------ bouton lien */
a.btn { display: inline-flex; align-items: center; min-height: 32px; padding: 4px 12px; border-radius: 8px; background: var(--good); color: #fff; font-weight: 600; font-size: .9rem; }
a.btn:hover { text-decoration: none; filter: brightness(1.05); }

/* ------------------------------------------------------------ script d'appel */
.script { display: flex; flex-direction: column; gap: 6px; }
.script details { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; }
.script summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.script .pitch { margin-top: 6px; }

/* ------------------------------------------------------------ rapport client */
body.reporting > *:not(#report) { display: none !important; }
.report { padding: 16px; }
.rp-bar { display: flex; justify-content: space-between; gap: 8px; max-width: 900px; margin: 0 auto 12px; }
.rp { max-width: 900px; margin: 0 auto; background: #fff; color: #16181d; border: 1px solid #e2e5ea; border-radius: 12px; padding: 32px;
  --surface-2: #f0f2f5; --muted: #5f6673; --border: #e2e5ea; --good: #1a7f4b; --good-soft: #e3f4ea; --warn: #a35d00; --warn-soft: #fdf0dc; --bad: #c0322b; --bad-soft: #fbe6e5; --accent-soft: #e8eefe; }
.rp h1 { font-size: 1.7rem; margin: 4px 0; }
.rp h2 { font-size: 1.1rem; margin: 26px 0 8px; padding-bottom: 6px; border-bottom: 2px solid #2f5bea; }
.rp h4 { margin: 14px 0 4px; }
.rp p, .rp li { font-size: .92rem; }
.rp-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: #2f5bea; font-weight: 700; }
.rp-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.rp-kpis > div { background: #f0f2f5; border-radius: 10px; padding: 12px; }
.rp-kpis .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rp-kpis .l { font-size: .78rem; color: #5f6673; }
.rp table { border: 1px solid #e2e5ea; border-radius: 8px; overflow: hidden; }
.rp th { background: #f0f2f5; color: #5f6673; }
.rp th, .rp td { border-color: #e2e5ea; white-space: normal; }
.rp-problems li { margin-bottom: 4px; }
.rp-foot { margin-top: 28px; padding-top: 12px; border-top: 1px solid #e2e5ea; }
@media (max-width: 860px) {
  .rp { padding: 18px; }
  .rp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp table { display: block; overflow-x: auto; }
}
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .rp-bar { display: none; }
  .report { padding: 0; }
  .rp { border: 0; padding: 0; max-width: none; }
  .rp h2 { break-after: avoid; }
  .rp table, .rp li { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
