:root {
  --bg: #0c0b12; --surface: #16141f; --surface-2: #1c1a28; --surface-3: #221f30;
  --ink: #eae8f2; --ink-strong: #ffffff; --muted: #948fab;
  --line: #2a2736; --line-strong: #38344a;
  --accent: #7c6cff; --accent-2: #a190ff; --accent-soft: #241f3d;
  --gold: #f0b429; --gold-soft: #2e2411;
  --danger: #ef4444; --danger-soft: #2a1518;
  --ok: #22c55e; --ok-soft: #122a1a;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font: "Public Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); margin: 0; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 12px; text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 15px; flex: none;
}
.brand b { font-size: 15px; letter-spacing: -0.01em; color: var(--ink-strong); }
.brand span { color: var(--muted); font-size: 11px; display: block; margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; padding: 0 10px; margin: 14px 0 6px;
}
.nav-label:first-child { margin-top: 0; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.nav a.active { background: var(--accent-soft); color: var(--ink-strong); }
.nav a.active svg { color: var(--accent-2); opacity: 1; }
.nav a:hover:not(.active) { background: var(--surface-2); color: var(--ink); text-decoration: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 30px;
  border-bottom: 1px solid var(--line); background: rgba(22,20,31,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 15px; font-weight: 600; color: var(--muted); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.level-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(240,180,41,.3);
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
}
.who-name { font-size: 13px; font-weight: 600; }
.logout { margin: 0; }

.content { padding: 30px; max-width: 1080px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
.page-head h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.sub { color: var(--muted); font-size: 13px; margin: 0; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }

/* ---------- Cards / forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 22px 26px; }

.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 19px; }
.login form { display: flex; flex-direction: column; gap: 12px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 11px; outline: none; width: 100%; resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface-3); }
input[type="file"] { color: var(--muted); font-size: 12.5px; }

button, .btn-link {
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer;
  border: 0; border-radius: 9px; padding: 9px 16px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-block; text-decoration: none;
}
button:hover, .btn-link:hover { filter: brightness(1.08); text-decoration: none; }
button.ghost, .ghost, .btn-link.ghost-link { background: none; color: var(--accent-2); border: 1px solid var(--line-strong); }
button.ghost:hover, .ghost:hover, .btn-link.ghost-link:hover { border-color: var(--accent); filter: none; }
button.sm { padding: 6px 12px; font-size: 12.5px; }

.error { color: var(--danger); font-size: 13px; margin: 0 0 12px; background: var(--danger-soft); border-radius: 9px; padding: 9px 13px; }
.ok-line { color: var(--ok); font-weight: 600; font-size: 13.5px; margin: 0 0 12px; background: var(--ok-soft); border-radius: 9px; padding: 9px 13px; display: inline-block; }

.success-form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.form-row { display: flex; gap: 14px; }
.form-row label { flex: 1; }
.absence-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- Home : hero niveau ---------- */
.level-hero {
  background: linear-gradient(150deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: 18px; padding: 28px 32px;
  display: flex; align-items: center; gap: 28px; position: relative; overflow: hidden; flex-wrap: wrap;
}
.level-hero::before {
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(240,180,41,.16), transparent 70%); pointer-events: none;
}
.level-medal {
  width: 84px; height: 84px; border-radius: 50%; flex: none; position: relative; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #ffe08a, var(--gold) 60%, #b8790f 100%);
  display: grid; place-items: center; font-size: 34px;
  box-shadow: 0 0 0 5px var(--gold-soft), 0 8px 20px rgba(240,180,41,.25);
}
.level-copy { position: relative; z-index: 1; flex: 1; min-width: 200px; }
.level-copy .eyebrow { font-size: 11px; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.level-copy h2 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.level-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.level-progress { width: 220px; flex: none; position: relative; z-index: 1; }
.level-progress .bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 8px; }
.level-progress .fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ffd873); border-radius: 999px; }
.level-progress .meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .val { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--ink-strong); margin-top: 6px; display: block; font-variant-numeric: tabular-nums; }
.stat.accent .val { color: var(--accent-2); }

/* ---------- Action tiles ---------- */
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; display: block; }
.tiles, .home-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink);
  transition: border-color .15s;
}
.tile:hover { border-color: var(--line-strong); text-decoration: none; }
.tile .tile-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; }
.tile.success .tile-ic { background: var(--ok-soft); }
.tile.fail .tile-ic { background: var(--danger-soft); }
.tile.absence .tile-ic { background: var(--accent-soft); }
.tile h2, .tile h3 { font-size: 14.5px; font-weight: 600; }
.tile p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; flex: 1; }
.tile .go { margin-top: auto; font-size: 12px; font-weight: 700; color: var(--accent-2); display: flex; align-items: center; gap: 4px; }

/* ---------- Leaderboard ---------- */
.board { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.board-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.board-row:last-child { border-bottom: 0; }
.board-row.me { background: var(--accent-soft); }
.rank { width: 22px; font-family: var(--mono); font-weight: 700; color: var(--muted); text-align: center; flex: none; }
.board-row.r1 .rank { color: var(--gold); }
.b-name { font-weight: 600; flex: 1; }
.b-meta { color: var(--muted); font-size: 12px; }
.b-amount { font-family: var(--mono); font-weight: 600; color: var(--accent-2); font-variant-numeric: tabular-nums; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .level-hero { flex-direction: column; align-items: flex-start; }
  .level-progress { width: 100%; }
}
@media (max-width: 480px) {
  .content { padding: 18px 16px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; row-gap: 8px; }
  .topbar h1 { flex-basis: 100%; }
  .who { margin-left: 0; flex-wrap: wrap; }
  .form-row { flex-direction: column; }
}
