:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --text: #16181d;
  --muted: #646b78;
  --line: #e3e6eb;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --bad: #c2410c;
  --bad-soft: #fdeee6;
  --warn: #a16207;
  --warn-soft: #fdf6dc;
  --side: #121420;
  --side-text: #c9ccd8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 18, 30, .06), 0 1px 1px rgba(16, 18, 30, .03);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --panel: #161922;
    --panel-2: #1b1f2a;
    --text: #e7e9ee;
    --muted: #9198a6;
    --line: #262b37;
    --accent: #8b85ff;
    --accent-soft: #23234a;
    --ok: #4ade80;
    --ok-soft: #15301f;
    --bad: #fb923c;
    --bad-soft: #3a2116;
    --warn: #facc15;
    --warn-soft: #332a10;
    --side: #0a0b10;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.55rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* --- Mise en page --- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--side);
  color: var(--side-text);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; padding: 4px 8px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #22d3ee); color: #fff; font-weight: 800;
}
.side a {
  color: var(--side-text); padding: 9px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center;
}
.side a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side a.on { background: rgba(255,255,255,.1); color: #fff; }
.side .ico { width: 18px; text-align: center; opacity: .85; }
.side .spacer { flex: 1; }
.side .who { font-size: .82rem; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; }
.side .who strong { color: #fff; display: block; }

main { padding: 28px 32px 60px; max-width: 1240px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card > .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .head { padding: 16px 18px 0; }

.kpi .label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* --- Tableaux --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

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

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.game { font-weight: 700; }
.game-valorant { color: #ff4655; }
.game-cs2 { color: #de9b35; }
.game-r6 { color: #3d8bd9; }
.game-rocket_league { color: #1a9fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

.kind-officiel { --k: #e11d48; }
.kind-scrim { --k: #4f46e5; }
.kind-entrainement { --k: #0891b2; }
.kind-reunion { --k: #ca8a04; }
.kind-autre { --k: #64748b; }

.score { font-weight: 700; font-variant-numeric: tabular-nums; }

/* --- Boutons & formulaires --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel);
  color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; line-height: 1.2;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }

form.stack { display: grid; gap: 14px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .88rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; min-width: 150px; padding: 7px 10px; }
.stat-input { width: 78px; padding: 6px 8px; text-align: right; }

/* --- Messages --- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash.error { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--accent-soft); color: var(--accent); }

/* --- Calendrier --- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 8px; font-size: .75rem; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--panel-2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel); position: relative; }
.cal .day.out { background: var(--panel-2); }
.cal .day.out .n { opacity: .45; }
.cal .day .n { font-size: .8rem; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.cal .day.today .n span { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; }
.cal .day .add { opacity: 0; color: var(--muted); }
.cal .day:hover .add { opacity: 1; }
.ev {
  display: block; margin-top: 4px; padding: 3px 6px; border-radius: 6px; font-size: .76rem; line-height: 1.3;
  background: color-mix(in srgb, var(--k) 14%, transparent); color: var(--text);
  border-left: 3px solid var(--k); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ev:hover { text-decoration: none; filter: brightness(.97); }
.ev b { font-weight: 700; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--k); display: inline-block; }

/* --- Barres finances --- */
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; align-items: end; height: 170px; padding-top: 10px; }
.bars .m { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 140px; width: 100%; justify-content: center; }
.bars .b { width: 42%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .in { background: var(--ok); }
.bars .out { background: var(--bad); }
.bars .lbl { font-size: .72rem; color: var(--muted); }

/* --- Auth --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { color: var(--text); padding: 0 0 18px; }

.profile-head { display: flex; gap: 16px; align-items: center; }
.avatar {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem;
  background: var(--accent-soft); color: var(--accent); flex-shrink: 0;
}
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

/* --- Mobile --- */
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 12px; gap: 2px; }
  .brand { padding: 4px 8px; width: 100%; }
  .side .spacer, .side .who { display: none; }
  .side a { padding: 7px 9px; font-size: .9rem; }
  main { padding: 20px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .span2 { grid-column: span 2; }
  .fields { grid-template-columns: 1fr; }
  .cal .day { min-height: 70px; }
  .ev { font-size: .68rem; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .cal .ev span.t { display: none; }
}
