:root {
	--bg: #f6f6f4;
	--surface: #ffffff;
	--surface-2: #f0f0ed;
	--border: #e2e2dd;
	--text: #161616;
	--muted: #6b6b66;
	--accent: #161616;
	--accent-text: #ffffff;
	--danger: #b42318;
	--danger-bg: #fdecea;
	--ok: #1f7a4d;
	--ok-bg: #e7f5ee;
	--warn: #8a5a00;
	--warn-bg: #fff4dc;
	--focus: #3b6fd8;
	--radius: 10px;
	color-scheme: light;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #111111;
		--surface: #1a1a1a;
		--surface-2: #232323;
		--border: #2e2e2e;
		--text: #ececea;
		--muted: #9a9a94;
		--accent: #ececea;
		--accent-text: #111111;
		--danger: #ff8a7f;
		--danger-bg: #3a1c19;
		--ok: #6fd3a0;
		--ok-bg: #16301f;
		--warn: #f5c76a;
		--warn-bg: #33280f;
		--focus: #7aa2f7;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	background: var(--bg);
	color: var(--text);
	font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p { margin: 0; }
a { color: inherit; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.pad { padding: 24px; }
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* Boutons et champs */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	height: 34px; padding: 0 14px; border-radius: 8px;
	border: 1px solid var(--border); background: var(--surface); color: var(--text);
	font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { opacity: 0.88; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
input[type="search"], input[type="email"], textarea {
	width: 100%; font: inherit; color: var(--text);
	background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 76px; resize: vertical; }
form { margin: 0; }

/* Pages simples */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card.narrow { max-width: 420px; width: 100%; display: grid; gap: 14px; padding: 28px; }

/* En-tête */
.topbar {
	position: sticky; top: 0; z-index: 5;
	display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
	padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: grid; line-height: 1.25; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.tab { font: inherit; border: 0; background: transparent; color: var(--muted); padding: 5px 14px; border-radius: 7px; cursor: pointer; font-weight: 500; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

/* Mise en page */
.app { max-width: 1200px; margin: 0 auto; padding: 24px; }
.split { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
.side { display: grid; gap: 6px; position: sticky; top: 84px; }
.side .label { margin: 4px 4px 6px; }
.mcp-item {
	display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
	font: inherit; color: inherit; text-align: left; cursor: pointer;
	background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 9px 12px;
}
.mcp-item:hover { background: var(--surface); }
.mcp-item[aria-current="true"] { background: var(--surface); border-color: var(--border); font-weight: 600; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; background: var(--surface-2); border-radius: 99px; padding: 1px 8px; }
.others { margin-top: 18px; padding: 12px; border-radius: 8px; border: 1px dashed var(--border); display: grid; gap: 8px; font-size: 12px; }
.others strong { font-weight: 600; }

.panel { display: grid; gap: 16px; }
.panel-head { display: grid; gap: 8px; }
.panel-head .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }
.notice strong { color: inherit; }

.add { display: grid; gap: 8px; }
.add .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }

.list-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.list-head input { max-width: 280px; }
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }
.list li .email { overflow-wrap: anywhere; }
.list li.empty { color: var(--muted); padding: 14px; justify-content: center; }

details.history { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.history summary { cursor: pointer; padding: 10px 14px; font-weight: 500; }
details.history ol { list-style: none; margin: 0; padding: 0 14px 12px; display: grid; gap: 8px; font-size: 13px; }
.plus { color: var(--ok); }
.minus { color: var(--danger); }

/* Vue par personne */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.matrix { border-collapse: collapse; width: 100%; min-width: 560px; }
.matrix th, .matrix td { padding: 8px 12px; border-top: 1px solid var(--border); text-align: left; }
.matrix thead th { border-top: 0; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.matrix td.c, .matrix th.c { text-align: center; width: 120px; }
.matrix input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.matrix tr.new td { background: var(--surface-2); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar > input { max-width: 320px; }
.inline-form { display: flex; gap: 8px; flex: 1 1 360px; max-width: 460px; }
.inline-form input { flex: 1; min-width: 0; }

.toast {
	position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
	max-width: min(560px, calc(100vw - 32px));
	background: var(--accent); color: var(--accent-text); padding: 10px 16px; border-radius: 8px;
	box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 20;
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
	.topbar { padding: 10px 16px; gap: 10px; }
	.me { margin-left: 0; width: 100%; justify-content: space-between; }
	.app { padding: 16px; }
	.split { grid-template-columns: 1fr; }
	.side { position: static; }
	.list-head input, .toolbar > input, .inline-form { max-width: none; }
}
