:root {
    --bg: #f6f7f9; --panel: #ffffff; --text: #1c2330; --muted: #66707f;
    --border: #dde2e9; --accent: #2456d6; --ok: #1a7f4b; --warn: #a86400; --error: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, "Segoe UI", sans-serif; }
main { max-width: 1200px; margin: 1.2rem auto; padding: 0 1rem; }

.topnav { display: flex; gap: .25rem; align-items: center; background: #1c2330; padding: .4rem 1rem; }
.topnav .brand { color: #fff; font-weight: 600; margin-right: 1rem; }
.topnav a { color: #c6cdd8; text-decoration: none; padding: .35rem .65rem; border-radius: 6px; }
.topnav a:hover { color: #fff; }
.topnav a.active { background: #33405c; color: #fff; }

.banner { max-width: 1200px; margin: .6rem auto 0; padding: .5rem .9rem; border-radius: 8px; }
.banner.ok { background: #e2f4e9; color: var(--ok); }
.banner.warn { background: #fdf1dc; color: var(--warn); }
.banner.error { background: #fbe4e2; color: var(--error); }

h1 { font-size: 1.35rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #eef1f5; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.new { background: #e3ecfd; color: var(--accent); }
.badge.transient { background: #fdf1dc; color: var(--warn); }
.badge.persistent { background: #fbe4e2; color: var(--error); }
.badge.resolved { background: #e2f4e9; color: var(--ok); }
.badge.reopened { background: #f6e3fb; color: #7b2d8b; }
.badge.gray { background: #edf0f4; color: var(--muted); }
.badge.ok { background: #e2f4e9; color: var(--ok); }
.badge.error { background: #fbe4e2; color: var(--error); }
.badge.warn { background: #fdf1dc; color: var(--warn); }
.badge.private { background: #efe6fb; color: #5b3a8c; }

a { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }

form.inline { display: inline; }
label { display: block; margin: .6rem 0 .2rem; font-weight: 600; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=date], select, textarea {
    width: 100%; max-width: 480px; padding: .45rem .6rem; border: 1px solid var(--border);
    border-radius: 8px; font: inherit; background: #fff;
}
textarea { max-width: 100%; min-height: 90px; }
.checks { display: flex; gap: 1rem; flex-wrap: wrap; margin: .4rem 0; }
.checks label { display: inline-flex; gap: .35rem; align-items: center; font-weight: 400; margin: 0; }

button, .btn {
    display: inline-block; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger, .btn.danger { color: var(--error); border-color: #eac5c3; }
button:hover, .btn:hover { filter: brightness(.97); }

.toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.filters { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { margin: 0 0 .2rem; font-size: .8rem; }
.filters input, .filters select { max-width: 180px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: .25rem .8rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.pagination { display: flex; gap: .3rem; margin-top: 1rem; }
.pagination a, .pagination span { padding: .25rem .6rem; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

pre.log { background: #1c2330; color: #d7dde7; padding: .8rem; border-radius: 8px; overflow-x: auto; font-size: .82rem; }

th.sortable { padding: 0; }
th.sortable a { display: block; padding: .5rem .7rem; color: inherit; text-decoration: none; }
th.sortable a:hover { color: var(--accent); }
th.sortable.sorted { background: #e4e9f1; }
.sort-ind { color: var(--muted); font-size: .75rem; }

.icon-btn { border: 1px solid transparent; background: none; padding: .15rem .35rem; font-size: 1rem; line-height: 1.2; border-radius: 6px; }
.icon-btn:hover { background: #eef1f5; border-color: var(--border); }
.icon-btn.has-note { background: #fdf1dc; }
.row-actions { white-space: nowrap; }
.row-flag { margin-left: .3rem; font-size: .9rem; cursor: help; }
tr.blacklisted > td { opacity: .55; }

.group-toggle { border: none; background: none; padding: 0 .25rem 0 0; font-size: .8rem; color: var(--muted); cursor: pointer; }
.group-toggle.placeholder { display: inline-block; width: 1.05rem; cursor: default; }
tr.subrow > td { background: #fafbfc; border-bottom: 1px dashed var(--border); font-size: .85rem; padding-top: .3rem; padding-bottom: .3rem; }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.3rem; max-width: 560px; width: 92%; color: var(--text); background: var(--panel); }
dialog::backdrop { background: rgba(20, 26, 38, .45); }
dialog .toolbar { margin: 0; }

a.badge { text-decoration: none; }
.panel .panel { margin-bottom: .6rem; }
.panel.analysis[data-source="incident"] { border-left: 3px solid var(--accent); }
.panel.analysis[data-source="sibling"] { border-left: 3px solid var(--border); }

/* Mode utilisateurs : visibilité privé/public, utilisateur connecté */
.visibility { white-space: nowrap; }
button.link { background: none; border: none; padding: 0 .2rem; color: var(--accent); cursor: pointer; font-size: .8rem; text-decoration: underline; }
.topnav .user { margin-left: auto; display: flex; gap: .5rem; align-items: center; color: #c6cdd8; }
.topnav .user button.link { color: #c6cdd8; }

/* Performances : gains par campagne */
.gains { --cand: #2a78d6; --wit: #eb6834; --grid: #eceff3; --good: var(--ok); --bad: var(--error); }
.gains h2 { margin: 0; }
.gains h3 { font-size: .92rem; margin: 0; }
.gains-head { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.gains-head select { max-width: 420px; }
.gains-controls { display: flex; gap: .6rem 1rem; align-items: end; flex-wrap: wrap; margin-bottom: .6rem; }
.gains-controls label { margin: 0; font-size: .8rem; }
.gains-controls select { max-width: 330px; display: block; margin-top: .2rem; }
.chips { display: flex; gap: .3rem; flex-wrap: wrap; }
.chips button { padding: .3rem .7rem; border-radius: 999px; font-size: .85rem; }
.chips button.active { background: #1c2330; border-color: #1c2330; color: #fff; }
.gains-headline { font-size: .95rem; margin: .4rem 0 .8rem; }
.gains .delta.good, .gain-tile .t-delta.good { color: var(--good); }
.gains .delta.bad, .gain-tile .t-delta.bad { color: var(--bad); }
.gains .delta.flat, .gain-tile .t-delta.flat { color: var(--muted); }
.gains-headline .delta { font-weight: 700; }
.gain-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-bottom: 1.2rem; }
.gain-tile { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; text-align: left; padding: .6rem .8rem; border-radius: 10px; }
.gain-tile.active { border-color: #1c2330; box-shadow: inset 0 0 0 1px #1c2330; }
.gain-tile .t-type { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.gain-tile .t-delta { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.gain-tile .t-sub { font-size: .8rem; font-variant-numeric: tabular-nums; }
.viz-head { display: flex; gap: .4rem 1rem; align-items: baseline; flex-wrap: wrap; margin: .8rem 0 .3rem; }
.viz-head .muted { font-size: .8rem; }
.viz { width: 100%; overflow: hidden; }
.viz svg { display: block; font: 12px system-ui, "Segoe UI", sans-serif; }
.viz .grid { stroke: var(--grid); stroke-width: 1; }
.viz .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .axis-rule { stroke: var(--border); }
.viz .hit { fill: transparent; }
.viz .bar-row { cursor: pointer; }
.viz .bar-row:hover .hit { fill: #f4f6f9; }
.viz .bar-row.is-cmp .hit { fill: #eef3fc; }
.viz .row-label { fill: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.viz .bar.candidate { fill: var(--cand); }
.viz .bar.witness { fill: var(--wit); }
.viz .bar.unreliable { opacity: .35; }
.viz .whisker { stroke-width: 1.5; }
.viz .whisker.candidate { stroke: var(--cand); }
.viz .whisker.witness { stroke: var(--wit); }
.viz .value { fill: var(--text); font-variant-numeric: tabular-nums; }
.viz text.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.viz text.delta.good { fill: var(--good); }
.viz text.delta.bad { fill: var(--bad); }
.viz text.delta.flat { fill: var(--muted); }
.viz .ref-rule { stroke: var(--text); stroke-width: 1; opacity: .35; }
.viz .tag { fill: #1c2330; }
.viz .tag-cmp { fill: var(--accent); }
.viz .tag-text { fill: #fff; font-size: 9.5px; font-weight: 700; letter-spacing: .03em; }
.viz .lane rect { stroke: #fff; stroke-width: 1; }
.viz .lane.candidate rect { fill: #dbe7f8; }
.viz .lane.witness rect { fill: #fbe1d6; }
.viz .lane.candidate.is-ref rect, .viz .lane.candidate.is-cmp rect { fill: #a9c8f0; }
.viz .lane.witness.is-ref rect, .viz .lane.witness.is-cmp rect { fill: #f5b9a0; }
.viz .lane-text { fill: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 10.5px; pointer-events: none; }
.viz .change-rule { stroke: var(--cand); stroke-width: 1; opacity: .45; }
.viz .dots circle { opacity: .35; }
.viz .dots.candidate circle, .viz .dots.candidate .clipped { fill: var(--cand); }
.viz .dots.witness circle, .viz .dots.witness .clipped { fill: var(--wit); }
.viz .median { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .median.candidate { stroke: var(--cand); }
.viz .median.witness { stroke: var(--wit); }
.viz .focus { fill: none; stroke-width: 2; }
.viz .focus.candidate { stroke: var(--cand); }
.viz .focus.witness { stroke: var(--wit); }
.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; }
.legend .swatch.candidate { background: var(--cand); }
.legend .swatch.witness { background: var(--wit); }
.inline-check { display: inline-flex; gap: .3rem; align-items: center; font-weight: 400; font-size: .8rem; margin: 0 0 0 auto; }
.viz-tip { position: fixed; z-index: 10; pointer-events: none; background: #1c2330; color: #eef1f5; padding: .45rem .6rem; border-radius: 8px; font-size: .8rem; line-height: 1.45; max-width: 360px; box-shadow: 0 4px 14px rgba(20, 26, 38, .25); }
.viz-tip .mono { font-size: .78rem; }
.small { font-size: .8rem; }
