/* Interface d'administration — même parti pris que le rapport :
   une seule typo lisible, palette neutre, couleur seulement quand elle informe. */

:root {
  --ink: #16181d;
  --muted: #5c6270;
  --faint: #8990a0;
  --line: #dfe2e7;
  --line-soft: #eef0f3;
  --paper: #f4f5f7;
  --surface: #fff;
  --good: #1a7f4b;
  --good-bg: #e8f5ee;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --warn: #a35c00;
  --warn-bg: #fdf0e0;
  --brand: #16181d;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 24px; letter-spacing: -0.01em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--ink); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }

/* ------------------------------------------------------------------ shell */
.topbar { background: var(--brand); color: #fff; }
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; gap: 20px; min-height: 56px;
}
.topbar a { color: rgba(255,255,255,.72); text-decoration: none; font-size: 14px; }
.topbar a:hover { color: #fff; }
.topbar .brand { font-weight: 600; color: #fff; font-size: 15px; }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }
.topbar button {
  background: transparent; border: 1px solid rgba(255,255,255,.28); color: rgba(255,255,255,.85);
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.topbar button:hover { border-color: #fff; color: #fff; }
.topbar select {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); color: #fff;
  font: inherit; font-size: 13.5px; padding: 5px 9px; border-radius: 6px;
}
.topbar select option { color: var(--ink); }

.tabs { background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs-in { max-width: 1120px; margin: 0 auto; padding: 0 22px; display: flex; gap: 4px; }
.tabs a {
  padding: 13px 14px; font-size: 14.5px; text-decoration: none; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 22px 70px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 14.5px; }

/* ----------------------------------------------------------------- blocs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card-pad { padding: 20px 22px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; }
.stat-sub { font-size: 13px; color: var(--muted); }

.delta { font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14.5px; }
.flash.ok { background: var(--good-bg); border: 1px solid #bfe0cd; }
.flash.err { background: var(--bad-bg); border: 1px solid #f3c7c1; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }

/* --------------------------------------------------------------- tableau */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 12.5px; font-weight: 600; color: var(--muted); border-bottom-color: var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: var(--line-soft); }
td.r, th.r { text-align: right; }
td a.row-link { text-decoration: none; display: block; }

/* ------------------------------------------------------------ formulaires */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=color], input[type=search],
select, textarea, input[type=file] {
  width: 100%; padding: 9px 11px; border: 1px solid #c9ced7; border-radius: 6px;
  font: inherit; font-size: 14.5px; background: #fff; color: var(--ink);
}
input[type=color] { padding: 3px; height: 38px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.field { margin-bottom: 16px; }
.row { display: grid; gap: 14px; margin-bottom: 14px; }
.checks { display: flex; gap: 20px; flex-wrap: wrap; margin: 6px 0 16px; }
.checks span { display: flex; align-items: center; gap: 7px; font-size: 14.5px; }
.checks input { accent-color: var(--ink); width: 15px; height: 15px; }
.checks label { margin: 0; font-size: 14.5px; color: var(--ink); font-weight: 400; }

button, .btn {
  font: inherit; font-size: 14.5px; font-weight: 500; padding: 10px 20px; border: 0;
  border-radius: 6px; background: var(--ink); color: #fff; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { background: #31353d; }
.btn-light, button.light {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
.btn-light:hover, button.light:hover { background: var(--line-soft); border-color: var(--faint); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 5px 11px; font-size: 13px; }
button.ghost:hover { background: var(--line-soft); color: var(--ink); }
button.danger { background: transparent; color: var(--bad); border: 1px solid #f3c7c1; padding: 5px 11px; font-size: 13px; }
button.danger:hover { background: var(--bad-bg); }

/* --------------------------------------------------------------- badges */
.pill { display: inline-block; font-size: 12.5px; font-weight: 500; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.pill.on { color: var(--good); border-color: #bfe0cd; background: var(--good-bg); }
.pill.off { color: var(--bad); border-color: #f3c7c1; background: var(--bad-bg); }
.pill.warn { color: var(--warn); border-color: #efd6ad; background: var(--warn-bg); }
/* ------------------------------------------------- sélecteur de période */
.periods { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.chip {
  display: inline-block; padding: 6px 13px; border-radius: 20px; font-size: 13.5px;
  text-decoration: none; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--faint); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 500; }
.chip-form { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chip-form input { padding: 5px 9px; font-size: 13.5px; }
.chip-form button { padding: 6px 13px; font-size: 13.5px; }
@media (max-width: 760px) { .chip-form { margin-left: 0; width: 100%; } }

.score { font-weight: 700; }
.score.good { color: var(--good); }
.score.bad { color: var(--bad); }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--line-soft); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

.filters { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 10px; align-items: end; }
.filters .field { margin: 0; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 20px; font-size: 14px; }
.pager a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none; }
.pager a:hover { border-color: var(--ink); }

@media (max-width: 900px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .tabs-in { overflow-x: auto; }
}
