:root {
  --bg: #f5f5f2; --card: #ffffff; --ink: #1c1d21; --muted: #6b6f78; --line: #e3e3de;
  --accent: #2f5bd3; --accent-ink: #fff; --ok: #1f8a4c; --warn: #b7791f; --err: #c0392b;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181d; --card: #20232a; --ink: #eceef2; --muted: #9aa0ab; --line: #30343c;
          --accent: #6d8ff0; --accent-ink: #0d1020; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 640px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 48px; }
h1 { font-size: 22px; margin: 4px 0 16px; display: flex; justify-content: space-between; align-items: center; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.title { font-size: 20px; font-weight: 650; margin: 0 0 2px; word-break: break-word; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
button { border: 0; border-radius: 12px; padding: 14px 16px; font-weight: 600; cursor: pointer; width: 100%;
         background: var(--accent); color: var(--accent-ink); margin-top: 12px; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.link { background: none; color: var(--muted); width: auto; padding: 4px 0; margin: 0; font-weight: 500; font-size: 14px; }
button:disabled { opacity: .5; cursor: default; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; }
.thumbs img, .thumbs div { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--bg); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
         background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.pret { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.badge.erreur { background: color-mix(in srgb, var(--err) 18%, transparent); color: var(--err); }
.badge.encours { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.item { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item a { color: var(--accent); font-weight: 600; text-decoration: none; }
.notice { border-left: 4px solid var(--warn); }
.error { color: var(--err); font-size: 14px; margin-top: 8px; }
.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
dialog { border: 0; border-radius: var(--radius); padding: 20px; width: min(92vw, 460px); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 12px 0; }
dt { color: var(--muted); } dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.hidden { display: none; }
.grow { flex: 1; }
.mt { margin-top: 10px; }
.between { justify-content: space-between; }
