@font-face { font-family: Manrope; font-weight: 500; font-display: swap; src: url(/fonts/manrope-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: Manrope; font-weight: 700; font-display: swap; src: url(/fonts/manrope-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: Manrope; font-weight: 800; font-display: swap; src: url(/fonts/manrope-latin-800-normal.woff2) format("woff2"); }

:root {
  --bg: #100f15; --surface: #17161d; --raised: #201e28; --line: #2c2a36; --line-strong: #423f50;
  --text: #f3f1f8; --muted: #a8a3b8; --accent: #9b6bff; --accent-soft: rgba(155, 107, 255, .16); --on-accent: #120c20;
  --good: #3ecf8e; --warn: #f2b84b; --bad: #ff6b74;
  --radius: 14px; --radius-s: 9px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-color: var(--line-strong) transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 15px/1.5 Manrope, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 16px; font-weight: 700; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 40vh 0 0; text-align: center; color: var(--muted); }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login > div { width: min(400px, 100%); display: grid; gap: 18px; justify-items: start; }
.login img { width: 52px; height: 52px; }
.login h1 { font-size: 34px; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px; border-right: 1px solid var(--line); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; min-width: 0; }
.brand img, .brand .ph { width: 36px; height: 36px; border-radius: 11px; flex: none; }
.brand .ph { display: grid; place-items: center; background: var(--accent-soft); font-weight: 800; }
.brand b { display: block; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: grid; gap: 3px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-s); color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a[aria-current] { background: var(--accent-soft); color: var(--text); }
.nav a[aria-current] svg { color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 0 8px; min-width: 0; }
.me > span:not(.avatar) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--raised); object-fit: cover; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; }
.main { padding: 36px 40px 120px; min-width: 0; }
.main > div { max-width: 980px; margin: 0 auto; display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.head p { color: var(--muted); margin-top: 5px; max-width: 62ch; }

/* ---------- Cartes et champs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 18px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.card > header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; align-items: flex-start; }
.card > header p { color: var(--muted); font-size: 14px; margin-top: 2px; max-width: 64ch; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 20px; align-items: start; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 16px; align-items: start; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-weight: 700; font-size: 14px; }
.field > small { color: var(--muted); font-size: 13px; line-height: 1.4; }
input[type=text], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-s);
}
input:hover, select:hover, textarea:hover { border-color: #5a566b; }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.unit { position: relative; display: block; }
.unit input { padding-right: 58px; }
.unit em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; font-size: 13px; pointer-events: none; }
input[type=number] { appearance: textfield; }
input::-webkit-inner-spin-button { appearance: none; }
input[type=color] { width: 100%; height: 42px; padding: 4px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-s); cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 42px; }
.toggle { display: flex; justify-content: space-between; gap: 18px; align-items: center; cursor: pointer; }
.toggle b { font-weight: 700; display: block; font-size: 14px; }
.toggle small { color: var(--muted); font-size: 13px; }
.toggle input { appearance: none; flex: none; width: 44px; height: 26px; margin: 0; border-radius: 20px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; left: 3px; top: 3px; background: #fff; transition: transform .15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(18px); }
.stack { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.rows { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.rows > * + * { border-top: 1px solid var(--line); padding-top: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-s); border: 1px solid var(--line-strong); background: var(--raised); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #2a2834; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: #ac84ff; }
.btn.danger { color: var(--bad); }
.btn.danger.primary { background: var(--bad); border-color: var(--bad); color: #24070a; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 8px 10px; }
.line .btn.ghost { font-size: 20px; line-height: 1; }
.btn.ghost:hover { background: var(--raised); color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; justify-self: start; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; }
.seg button { border: 0; background: none; padding: 6px 13px; min-height: 34px; border-radius: 8px; color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--raised); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 4px 4px 11px; min-height: 32px; border-radius: 20px; background: var(--raised); border: 1px solid var(--line); font-size: 13px; font-weight: 700; max-width: 100%; }
.chip button { border: 0; background: none; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); cursor: pointer; line-height: 1; font-size: 16px; }
.chip button:hover { background: var(--line-strong); color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 40px; gap: 10px; align-items: center; }
.line.reward { grid-template-columns: 120px minmax(0, 1fr) 40px; }
.line .name { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 700; font-size: 14px; }
.line .name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .why { grid-column: 1 / -1; color: var(--warn); font-size: 13px; }
.notice { border: 1px solid rgba(242, 184, 75, .4); background: rgba(242, 184, 75, .08); border-radius: var(--radius); padding: 14px 18px; display: grid; gap: 4px; font-size: 14px; }
.notice b { color: var(--warn); }
.empty { color: var(--muted); padding: 14px 0; font-size: 14px; }

/* ---------- Vue d'ensemble ---------- */
.status { display: flex; align-items: center; gap: 18px; justify-content: space-between; flex-wrap: wrap; }
.status .state { display: flex; align-items: center; gap: 12px; }
.status .dot { width: 12px; height: 12px; }
.status.on .dot { background: var(--good); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.kpis > div { padding: 18px 22px; min-width: 0; }
.kpis > div + div { border-left: 1px solid var(--line); }
.kpis span { color: var(--muted); font-size: 13px; }
.kpis b { display: block; font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .area { fill: var(--accent); opacity: .1; }
.chart .stroke { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; }
.chart .mark { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius-s); padding: 7px 11px; font-size: 13px; white-space: nowrap; }
.tip b { display: block; font-size: 15px; }
.tip span { color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; width: max-content; }
details[open] summary { margin-bottom: 10px; }

/* ---------- Tableaux ---------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 500; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
td .who { display: flex; align-items: center; gap: 11px; font-weight: 700; min-width: 0; }
td .who span:last-child { overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
td.wrap { white-space: normal; min-width: 220px; }
.max-h { max-height: 320px; overflow: auto; }

/* ---------- Aperçus ---------- */
.discord { background: #313338; border-radius: var(--radius-s); padding: 16px; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; color: #dbdee1; font-size: 15px; }
.discord .avatar { width: 40px; height: 40px; background: var(--accent); color: var(--on-accent); }
.discord .author { font-weight: 700; color: #fff; display: flex; gap: 7px; align-items: center; }
.discord .author i { font-style: normal; font-size: 10px; background: #5865f2; border-radius: 4px; padding: 0 5px; }
.discord .embed { background: #2b2d31; border-left: 4px solid var(--accent); border-radius: 4px; padding: 12px 14px; margin-top: 6px; display: flex; justify-content: space-between; gap: 12px; max-width: 440px; }
.discord .embed .avatar { width: 56px; height: 56px; border-radius: 6px; }
.discord .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.discord mark { background: rgba(88, 101, 242, .3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; }
.vars button { border: 1px solid var(--line); background: var(--raised); border-radius: 7px; padding: 4px 9px; font: 500 13px ui-monospace, Consolas, monospace; cursor: pointer; }
.vars button:hover { border-color: var(--accent); }
.rank-preview { width: 100%; aspect-ratio: 934 / 282; display: block; }

/* ---------- Barre d'enregistrement, messages, fenêtres ---------- */
.savebar { position: fixed; left: calc(248px + 24px); right: 24px; bottom: 22px; max-width: 980px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 12px 12px 20px; background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 14px 40px rgba(0, 0, 0, .5); z-index: 20; font-weight: 700; }
#toasts { position: fixed; right: 22px; top: 22px; display: grid; gap: 10px; z-index: 60; max-width: min(380px, calc(100vw - 44px)); }
.toast { background: var(--raised); border: 1px solid var(--line-strong); border-left: 4px solid var(--good); border-radius: var(--radius-s); padding: 12px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); font-size: 14px; }
.toast.bad { border-left-color: var(--bad); }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 18px; padding: 24px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(8, 7, 12, .7); }
dialog form { display: grid; gap: 18px; }
dialog h2 { font-size: 19px; font-weight: 800; }
dialog .actions { justify-content: flex-end; }

/* ---------- Classement public ---------- */
.board { max-width: 780px; margin: 0 auto; padding: 48px 20px 80px; display: grid; gap: 26px; }
.board .top { display: flex; align-items: center; gap: 18px; }
.board .top img { width: 64px; height: 64px; border-radius: 19px; }
.board ol { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.board li { display: grid; grid-template-columns: 44px 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 18px; }
.board li + li { border-top: 1px solid var(--line); }
.board .pos { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.board li.lead .pos { color: var(--accent); }
.board li .avatar { width: 40px; height: 40px; }
.board .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .lvl { text-align: right; font-variant-numeric: tabular-nums; }
.board .lvl b { display: block; font-weight: 800; }
.bar { height: 6px; border-radius: 6px; background: var(--raised); overflow: hidden; margin-top: 6px; max-width: 280px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { flex: 1; }
  .me { margin: 0; }
  .me > span:not(.avatar) { display: none; }
  .nav { order: 3; display: flex; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav a { flex: none; min-height: 42px; }
  .main { padding: 24px 16px 130px; }
  .savebar { left: 12px; right: 12px; bottom: 12px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis > div { padding: 14px 16px; }
  .kpis > div:nth-child(3) { border-left: 0; }
  .kpis > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .card { padding: 18px 16px; }
  .line, .line.reward { grid-template-columns: minmax(0, 1fr) 92px 40px; }
  .line.reward { grid-template-columns: 92px minmax(0, 1fr) 40px; }
  .board li { grid-template-columns: 32px 40px minmax(0, 1fr) auto; padding: 12px; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
