/* mel status — feuille de style unique, aucune ressource externe.
   Les jetons de couleur sont ceux du dashboard pr_stats (palette catégorielle validée :
   5 teintes + gris), pour que les deux outils se ressemblent. Thème clair et sombre
   choisis tous les deux, pas un inversement automatique. */

*, *::before, *::after { box-sizing: border-box; }
:root {
  color-scheme: light;
  --page:      #f9f9f7;
  --surface:   #fcfcfb;
  --surface-2: #f2f1ec;
  --ink:       #0b0b0b;
  --ink-2:     #52514e;
  --muted:     #898781;
  --grid:      #e1e0d9;
  --axis:      #c3c2b7;
  --border:    rgba(11,11,11,0.10);
  --series-1:  #2a78d6;
  --series-2:  #eb6834;
  --series-3:  #1baf7a;
  --series-4:  #eda100;
  --series-5:  #e87ba4;
  --series-0:  #c3c2b7;
  --good:      #0ca30c;
  --warning:   #fab219;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --series-4: #c98500; --series-5: #d55181; --series-0: #383835;
    --good: #35b135; --warning: #d79b12;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --series-4: #c98500; --series-5: #d55181; --series-0: #383835;
  --good: #35b135; --warning: #d79b12;
}

body {
  margin: 0; padding: 0 clamp(14px, 3.5vw, 40px) 56px;
  background: var(--page); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--series-1); }

/* --- en-tête ------------------------------------------------------------------- */
header {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center;
  padding: 18px 0 14px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
  position: sticky; top: 0; background: var(--page); z-index: 5;
}
.brand { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.brand span { color: var(--muted); font-weight: 400; }
.spacer { flex: 1 1 auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.chip b { color: var(--ink); font-weight: 600; }
button, .btn {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  cursor: pointer;
}
button:hover { color: var(--ink); border-color: var(--axis); }
button[disabled] { opacity: .5; cursor: default; }

/* --- grille de cartes ---------------------------------------------------------- */
/* `align-items: start` : une carte courte ne s'étire pas à la hauteur de sa voisine
   — sinon une liste vide occupe une demi-page de vide. */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, 1fr);
  align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 18px; grid-column: span 12; min-width: 0;
}
.card.half { grid-column: span 6; }
.card.third { grid-column: span 4; }
@media (max-width: 900px) { .card.half, .card.third { grid-column: span 12; } }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.card .cap { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.card .cap:last-child { margin-bottom: 0; }

/* --- tuiles de chiffres -------------------------------------------------------- */
/* `auto-fit` plutôt que 4 colonnes fixes : la page « astreinte » en affiche cinq, et une
   grille rigide laissait la cinquième tuile seule sur une ligne à moitié vide. */
.tiles { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile {
  background: var(--surface-2); border-radius: 10px; padding: 12px 14px;
  border: 1px solid var(--border);
}
.tile .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .value .unit { font-size: 14px; font-weight: 500; color: var(--muted);
  margin-left: 3px; }
.tile .foot { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.up { color: var(--good); } .down { color: var(--series-2); }

/* --- niveau -------------------------------------------------------------------- */
.level { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.level-badge {
  width: 64px; height: 64px; border-radius: 16px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--series-1); color: #fff;
  line-height: 1;
}
.level-badge .n { font-size: 26px; font-weight: 700; }
.level-badge .t { font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em;
  opacity: .85; margin-top: 2px; }
.level-main { flex: 1 1 260px; min-width: 200px; }
.level-main .row { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--series-1); border-radius: 999px; }

/* --- objectifs ----------------------------------------------------------------- */
.quests { display: flex; flex-direction: column; gap: 12px; }
.quest { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px;
  align-items: center; }
.quest .mark {
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  border: 1px solid var(--axis); color: transparent; font-size: 13px; font-weight: 700;
}
.quest.done .mark { background: var(--series-3); border-color: var(--series-3);
  color: #fff; }
.quest .body { min-width: 0; }
.quest .name { font-size: 13.5px; margin-bottom: 5px; }
.quest.done .name { color: var(--ink-2); }
.quest .num { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.quest .bar { height: 6px; }
.quest.done .bar > i { background: var(--series-3); }

/* --- badges à paliers ---------------------------------------------------------- */
/* Quatre « métaux » : le palier se lit à la couleur, mais aussi à la couronne de points
   de la médaille et au libellé — jamais à la couleur seule. */
:root {
  --metal-0: #b8b6ae;   /* rien encore */
  --metal-1: #b5793f;   /* bronze */
  --metal-2: #8b95a1;   /* argent */
  --metal-3: #d99b00;   /* or */
  --metal-4: #2ba3bd;   /* diamant */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --metal-0: #4a4a46; --metal-1: #c08a52; --metal-2: #a3adb9;
    --metal-3: #eab308; --metal-4: #45c2da;
  }
}
:root[data-theme="dark"] {
  --metal-0: #4a4a46; --metal-1: #c08a52; --metal-2: #a3adb9;
  --metal-3: #eab308; --metal-4: #45c2da;
}

.badges { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.badge { border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  background: var(--surface-2); }
.badge .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.badge .who { min-width: 0; }
.badge .title { font-size: 13.5px; font-weight: 600; color: var(--ink);
  line-height: 1.25; }
.badge.t0 .title { color: var(--ink-2); }
.badge .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.badge .meta.next { margin: 6px 0 0; }
.badge .bar { height: 5px; }

.medal { flex: 0 0 auto; overflow: visible; }
.medal .plate { fill: var(--surface); stroke: var(--metal-0); stroke-width: 1.5; }
.medal .glyph { color: var(--metal-0); }
.medal .dot { fill: var(--surface); stroke: var(--metal-0); stroke-width: 1.2; }
.medal .dot.on { fill: currentColor; stroke: none; }
.medal.t1 { color: var(--metal-1); } .medal.t2 { color: var(--metal-2); }
.medal.t3 { color: var(--metal-3); } .medal.t4, .medal.t5 { color: var(--metal-4); }
.medal.t1 .plate, .medal.t2 .plate, .medal.t3 .plate,
.medal.t4 .plate, .medal.t5 .plate { stroke: currentColor; }
.medal.t1 .glyph, .medal.t2 .glyph, .medal.t3 .glyph,
.medal.t4 .glyph, .medal.t5 .glyph { color: currentColor; }
.badge.t1 .bar > i { background: var(--metal-1); }
.badge.t2 .bar > i { background: var(--metal-2); }
.badge.t3 .bar > i { background: var(--metal-3); }
.badge.t4 .bar > i, .badge.t5 .bar > i { background: var(--metal-4); }
.badge.t0 .bar > i { background: var(--metal-0); }

/* L'échelle complète, en petits jalons : on voit d'où l'on vient et où l'on va. */
.ladder { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.ladder .step { font-size: 10.5px; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
  cursor: help; }
/* Survol et focus visibles : `bindTip` rend ces jalons atteignables au clavier
   (tabindex), donc le focus doit se voir autant que le survol. */
.ladder .step:hover, .medal-wrap:hover { border-color: var(--axis); }
.ladder .step:focus-visible, .medal-wrap:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 2px; border-radius: 999px; }
.medal-wrap { display: inline-flex; cursor: help; border-radius: 12px; }
.ladder .step.on { border-color: transparent; background: var(--surface);
  color: var(--ink-2); font-weight: 600; }

/* --- listes -------------------------------------------------------------------- */
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.mine td { background: var(--surface-2); font-weight: 600; }
.pill { font-size: 11.5px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2); }
.pill.warn { border-color: var(--warning); color: var(--warning); }

/* --- graphiques ---------------------------------------------------------------- */
.plot { overflow-x: auto; }
.plot svg { display: block; max-width: 100%; height: auto; }
.axis-text { font-size: 10.5px; fill: var(--muted); }
.axis-text.strong { fill: var(--ink-2); }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px;
  font-size: 12.5px; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* --- infobulle ----------------------------------------------------------------- */
.tip {
  position: fixed; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; color: var(--ink-2); z-index: 20;
  box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 280px;
}
.tip .t { color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.tip .r { display: flex; gap: 10px; justify-content: space-between; }
.tip .v { color: var(--ink); font-variant-numeric: tabular-nums; }

/* --- barème & pied ------------------------------------------------------------- */
.rules { display: grid; gap: 4px 18px; grid-template-columns: 1fr auto;
  font-size: 13px; color: var(--ink-2); max-width: 520px; }
.rules b { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
footer { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px; max-width: 90ch; }
footer strong { color: var(--ink-2); }

/* --- login --------------------------------------------------------------------- */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login {
  width: min(360px, 92vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 24px;
}
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.login input {
  width: 100%; font: inherit; padding: 9px 11px; border-radius: 8px; color: var(--ink);
  border: 1px solid var(--axis); background: var(--page); margin-bottom: 14px;
}
.login button { width: 100%; padding: 10px; background: var(--series-1); color: #fff;
  border-color: transparent; font-weight: 600; }
.login .error { color: var(--series-2); font-size: 13px; margin: 0 0 12px; }

/* --- onglets ------------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 2px;
  border-radius: 9px; border: 1px solid var(--border); }
.tab { font-size: 13px; padding: 4px 12px; border-radius: 7px; text-decoration: none;
  color: var(--ink-2); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.10); }
.chip select { font: inherit; font-size: 12.5px; border: 0; background: transparent;
  color: var(--ink); padding: 0; }

/* --- bascule segmentée (classement : total / par jour) ------------------------- */
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.card-head .spacer { flex: 1 1 auto; }
.seg { display: flex; gap: 2px; background: var(--surface-2); padding: 2px;
  border-radius: 8px; border: 1px solid var(--border); flex: 0 0 auto; }
.seg button { border: 0; background: transparent; padding: 3px 10px; font-size: 12.5px;
  border-radius: 6px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink);
  font-weight: 600; }

/* `.chip` est en inline-flex : sans cette règle, l'attribut `hidden` ne masque rien
   (le display de la classe gagne) et une pastille vide reste dans l'en-tête. */
.chip[hidden] { display: none; }

tfoot td { border-bottom: 0; border-top: 1px solid var(--axis); padding-top: 8px; }

/* --- page profil ---------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack label { font-size: 12px; color: var(--muted); margin-top: 8px; }
.stack input[type="password"], .stack input[type="text"], .stack input[type="email"] {
  font: inherit; padding: 8px 10px; border-radius: 8px; color: var(--ink);
  border: 1px solid var(--axis); background: var(--page); max-width: 420px; }
.stack input[type="file"] { font-size: 13px; color: var(--ink-2); }
select { font: inherit; font-size: 13px; padding: 6px 8px; border-radius: 8px;
  color: var(--ink); border: 1px solid var(--axis); background: var(--page); }
/* Un champ figé doit se voir : sinon on croit pouvoir corriger l'adresse épinglée. */
input[readonly] { color: var(--muted); background: var(--surface-2); cursor: default; }
.row label { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px;
  flex-wrap: wrap; }
.profil-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.profil-mail { font-size: 15px; font-weight: 600; }
.avatar { width: 64px; height: 64px; border-radius: 16px; object-fit: cover;
  border: 1px solid var(--border); flex: 0 0 auto; background: var(--surface-2); }
.avatar-vide { display: grid; place-items: center; font-size: 22px; font-weight: 600;
  color: var(--muted); }
.msg { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--surface); }
.msg.ok { border-color: var(--good); color: var(--ink); }
.msg.ko { border-color: var(--series-2); color: var(--ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.login label + input { margin-bottom: 10px; }

/* --- page profil : sections, lignes, détails repliés ---------------------------- */
.profil-bandeau { display: flex; gap: 14px; align-items: center; margin: 4px 0 18px; }
.profil-mail { font-size: 16px; font-weight: 600; }

/* Ancres de section : on saute d'un bloc à l'autre sans dérouler toute la page. */
.anchors { display: flex; gap: 4px; margin: 0 0 4px; flex-wrap: wrap; }
.anchors a { font-size: 12.5px; padding: 4px 10px; border-radius: 999px;
  text-decoration: none; color: var(--ink-2); border: 1px solid var(--border); }
.anchors a:hover { color: var(--ink); border-color: var(--axis); }
h2.section { font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 500; margin: 26px 0 10px; }
h2.section:first-of-type { margin-top: 18px; }
/* L'ancre ne doit pas glisser sous l'en-tête collant. */
h2.section[id] { scroll-margin-top: 70px; }

/* Une ligne de réglage : nom + état + action, alignés en colonnes. */
.lignes { display: flex; flex-direction: column; }
.ligne { display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.ligne:first-child { border-top: 0; padding-top: 2px; }
.ligne.enfant { padding-left: 18px; position: relative; }
.ligne.enfant::before { content: "↳"; position: absolute; left: 2px;
  color: var(--muted); font-size: 12px; }
.ligne-nom { font-size: 13.5px; display: flex; gap: 8px; align-items: baseline;
  flex-wrap: wrap; }
.ligne-etat, .ligne-action { display: flex; gap: 6px; align-items: center; }
.ligne-action form { display: inline; }

/* Le « pourquoi » replié : présent, jamais imposé. */
details.why { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 8px; }
details.why > summary, details.edit > summary {
  cursor: pointer; font-size: 12px; color: var(--muted); list-style: none;
  display: inline-flex; align-items: center; gap: 5px; }
details > summary::-webkit-details-marker { display: none; }
details.why > summary::before, details.edit > summary::before {
  content: "▸"; font-size: 10px; transition: transform .12s; }
details[open].why > summary::before, details[open].edit > summary::before {
  transform: rotate(90deg); }
details.why > summary:hover, details.edit > summary:hover { color: var(--ink); }
details.why p { font-size: 12.5px; color: var(--muted); margin: 8px 0 0;
  max-width: 78ch; line-height: 1.5; }
details.edit { margin-top: 10px; }
details.edit > summary { color: var(--ink-2); }
details.edit form { margin-top: 8px; }
details.edit input[type="password"], details.edit input[type="text"],
details.edit input[type="email"], .row input[type="search"], .row input[type="email"],
.row input[type="text"] {
  font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 8px;
  color: var(--ink); border: 1px solid var(--axis); background: var(--page);
  min-width: 220px; }

/* Le lien à usage unique : mis en évidence, sélectionnable d'un geste. */
.lien-frais { border: 1px solid var(--good); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 12px; background: var(--surface-2); }
.lien-frais p { margin: 6px 0 0; word-break: break-all; user-select: all; }

/* Boutons destructeurs : reconnaissables sans être criards. */
button.croix { padding: 3px 8px; line-height: 1.1; color: var(--muted); }
button.croix:hover { color: var(--series-2); border-color: var(--series-2); }
button.danger { border-color: var(--series-2); color: var(--series-2); }
button.danger:hover { background: var(--series-2); color: #fff; }

.pill.ok { border-color: var(--good); color: var(--good); }
td.nowrap, .nowrap { white-space: nowrap; }
/* Vingt-trois dépôts : on les fait défiler dans la carte plutôt que dans la page. */
.tablewrap.scroll { max-height: 340px; overflow-y: auto; }
.tablewrap.scroll thead th { position: sticky; top: 0; background: var(--surface);
  z-index: 1; }
tr[hidden] { display: none; }

/* Un champ de mot de passe large comme la carte donne une cible démesurée pour douze
   caractères : on le borne, et on resserre le rythme vertical du formulaire. */
.card .stack { gap: 4px; }
.card .stack label { margin-top: 10px; }
.card .stack input[type="password"], .card .stack input[type="text"],
.card .stack input[type="email"] { max-width: 340px; padding: 7px 10px; font-size: 13.5px; }
/* Tableaux de réglages : plus denses que ceux des tableaux de bord. */
.card .tablewrap table { font-size: 12.5px; }
.card .tablewrap th, .card .tablewrap td { padding: 5px 10px 5px 0; }
.card .tablewrap td.mono { font-size: 12.5px; }
