:root {
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --line: #e3e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #e8f0fb;
  --good: #0a7a3d; --good-bg: #e6f4ec;
  --bad: #b3261e;  --bad-bg: #fbe9e8;
  --new: #6250d6;  --new-bg: #eeebfb;
  --warn: #8a5a00; --warn-bg: #fdf3dc;
  --flat-bg: #efeeea;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-0);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header.top {
  display: flex; align-items: center; gap: 24px; padding: 10px 24px;
  background: var(--surface-1); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.top .logo { font-weight: 700; font-size: 16px; color: var(--text-primary); }
header.top .logo span { color: var(--accent); }
header.top nav { display: flex; gap: 16px; margin-left: auto; color: var(--text-secondary); }
header.top nav a { color: var(--text-secondary); }
main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; }
h1 { font-size: 22px; margin: 4px 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g2, .g4 { grid-template-columns: 1fr; } }

/* Barre de filtres */
form.filtres { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
form.filtres label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=date], select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 120px;
}
button, .btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; cursor: pointer; font-weight: 600;
}
button.sec { background: #fff; color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg input { display: none; }
.seg label { padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--text-secondary); flex-direction: row !important; }
.seg input:checked + span { color: #fff; }
.seg label:has(input:checked) { background: var(--accent); color: #fff; }

.catpick { position: relative; min-width: 380px; }
.catpick .choix { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.catlist { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; max-height: 340px; overflow: auto; z-index: 20; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.catlist a { display: block; padding: 7px 10px; color: var(--text-primary); border-bottom: 1px solid var(--line); }
.catlist a:hover { background: var(--accent-soft); text-decoration: none; }
.catlist .n { float: right; color: var(--text-muted); font-size: 12px; }

/* Indicateurs */
.kpi .v { font-size: 26px; font-weight: 700; }
.kpi .l { color: var(--text-secondary); font-size: 12px; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:hover td { background: #faf9f6; }
.titre { max-width: 460px; }
.titre .m { color: var(--text-muted); font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-up { background: var(--good-bg); color: var(--good); }
.b-down, .b-out { background: var(--bad-bg); color: var(--bad); }
.b-new { background: var(--new-bg); color: var(--new); }
.b-flat { background: var(--flat-bg); color: var(--text-secondary); }
.b-vol { background: var(--warn-bg); color: var(--warn); }
.score { display: inline-flex; align-items: center; gap: 6px; }
.score .bar { width: 46px; height: 6px; border-radius: 3px; background: var(--flat-bg); overflow: hidden; }
.score .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.delta-up { color: var(--good); font-weight: 600; }
.delta-down { color: var(--bad); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: none; border: none; color: var(--text-secondary); padding: 8px 12px; border-radius: 0; font-weight: 600; }
.tabs button.on { color: var(--accent); border-bottom: 2px solid var(--accent); }
.tab { display: none; }
.tab.on { display: block; }

.rapport p { line-height: 1.6; margin: 0 0 10px; }
.rapport h3 { margin-top: 14px; }
.alerte { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.fil { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.chart { width: 100%; height: 380px; }
.login { max-width: 380px; margin: 12vh auto; }
.login form { display: grid; gap: 12px; }
.erreur { color: var(--bad); }
.ok { color: var(--good); }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
#chargement { display: none; position: fixed; inset: 0; background: rgba(252,252,251,.7); z-index: 50;
  align-items: center; justify-content: center; font-weight: 600; color: var(--text-secondary); }
