:root {
  color-scheme: light;
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --head: #E3E8EF;
  --ink: #18202E;
  --muted: #5B6576;
  --line: #D6DCE5;
  --accent: #1F6F8B;
  --accent-ink: #FFFFFF;
  --error: #B42318;
  --error-bg: #FDECEA;
  --ok: #1E7F4F;
  --focus: #1F6F8B;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #141922;
    --surface: #1B212C;
    --head: #222A36;
    --ink: #E6EAF0;
    --muted: #97A1B2;
    --line: #2C3442;
    --accent: #4FB3D4;
    --accent-ink: #0E1A20;
    --error: #F28B82;
    --error-bg: #3A1D1B;
    --ok: #5CC28A;
    --focus: #4FB3D4;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 14px/1.4 "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
button, input, select { font: inherit; color: inherit; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { height: 52px; width: auto; display: block; }
.brand picture + div { padding-left: 14px; border-left: 1px solid var(--line); }
.bar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.bar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.toolbar input[type=search] {
  width: 280px; max-width: 100%; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
#counts { color: var(--muted); font-size: 13px; }
.actions { margin-left: auto; display: flex; gap: 8px; }
button {
  padding: 7px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
button.link { border: 0; background: none; padding: 0; text-decoration: underline; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

main { flex: 1; overflow: auto; position: relative; }
table { border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--surface); }
th, td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; height: 40px; }
th {
  position: sticky; top: 0; z-index: 2; background: var(--head);
  text-align: center; font-weight: 500; font-size: 13px;
}
th button {
  width: 100%; height: 100%; border: 0; border-radius: 0; background: none;
  text-align: center; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
th .sort { color: var(--muted); margin-left: 4px; }



td { position: relative; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- KPI ---------- */
.kpis { display: flex; gap: 12px; flex-wrap: wrap; padding: 14px 20px 4px; }
.kpi {
  --tag: var(--accent);
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 170px; padding: 10px 16px; text-align: left;
  border: 1px solid var(--line); border-left: 4px solid var(--tag); border-radius: 8px; background: var(--surface);
}
.kpi-n { font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi-l { color: var(--muted); font-size: 13px; }
.kpi.on { box-shadow: inset 0 0 0 2px var(--tag); }

/* ---------- Filtres de la barre d'outils ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; max-width: 230px;
}
.filters select.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

/* ---------- Cellules ---------- */
td { position: relative; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center; padding: 0 8px; }
th.align-left, th.align-left button, td.align-left { text-align: left; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
td a { color: var(--accent); text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }
td.muted { color: var(--muted); }
td.strong { font-weight: 600; }
td.has-tip { cursor: help; }
td.c-approvals.ok { color: var(--ok); font-weight: 600; }
td.c-approvals.ko { color: var(--error); font-weight: 600; }

/* Valeur colorée (État, Statut) : fond teinté et pastille */
tbody tr td.tagged { background: color-mix(in srgb, var(--tag) 16%, var(--surface)); padding-left: 26px; }
td.tagged::after {
  content: ""; position: absolute; left: 10px; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 50%; background: var(--tag); pointer-events: none;
}
td.tagged a { color: var(--ink); }

main.busy table { pointer-events: none; opacity: .6; }
#empty { padding: 48px 20px; color: var(--muted); max-width: 640px; }
#empty strong { color: var(--ink); display: block; margin-bottom: 6px; }
@media (max-width: 720px) {
  .bar, .toolbar, .kpis { padding-left: 16px; padding-right: 16px; }
  .kpi { min-width: 0; flex: 1 1 140px; }
  .actions { margin-left: 0; width: 100%; }
  .actions button { flex: 1; }
}

/* ---------- Grouper par équipe ---------- */
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.toggle input { margin: 0; accent-color: var(--accent); }
tbody tr.group-row td.group {
  position: sticky; left: 0; height: 36px; padding: 0 12px; text-align: left;
  background: var(--head); border-top: 2px solid var(--line);
}
td.group strong { font-size: 14px; margin-right: 10px; }
td.group .group-n { color: var(--muted); font-size: 13px; margin-right: 14px; }
td.group .chip {
  --tag: var(--muted);
  display: inline-block; margin-right: 6px; padding: 1px 8px; border-radius: 10px; font-size: 12px;
  background: color-mix(in srgb, var(--tag) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tag) 45%, transparent);
}
tbody tr.group-row:hover td { background: var(--head); }
