:root {
  --bg: #f6f2ec; --surface: #fffdf9; --surface-2: #efe9e0; --line: #e2dacd;
  --ink: #221e18; --ink-2: #6d6558; --accent: #1f6f5c; --accent-ink: #fff;
  --ok: #2f8a4e; --warn: #c07a12; --bad: #c2412d;
  --fresh: #2f8a4e; --stale: #c07a12; --old: #c2412d;
  --radius: 14px; --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 4px 14px rgb(40 30 10 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16140f; --surface: #201d17; --surface-2: #2a261f; --line: #37322a;
    --ink: #eee8de; --ink-2: #a39a8b; --accent: #4fb89b; --accent-ink: #0d1f1a;
    --ok: #57b879; --warn: #e0a043; --bad: #ea6f5a;
    --fresh: #57b879; --stale: #e0a043; --old: #ea6f5a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 48px; }
h1 { font-size: 20px; line-height: 1.25; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
code { font: 12px/1.4 ui-monospace, Consolas, monospace; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.center { text-align: center; }

/* En-tête */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -.02em; text-decoration: none; color: var(--accent); }
.top nav { display: flex; gap: 4px; }
.top nav a { text-decoration: none; padding: 7px 12px; border-radius: 999px; color: var(--ink-2); font-weight: 600; }
.top nav a.on { background: var(--surface-2); color: var(--ink); }

/* Bandeaux, pastilles */
.banner { margin: 0; padding: 10px 16px; font-size: 14px; text-align: center; }
.banner.bad { background: color-mix(in srgb, var(--bad) 14%, var(--bg)); color: var(--ink); border-bottom: 1px solid var(--bad); }
.banner.ok { background: color-mix(in srgb, var(--ok) 14%, var(--bg)); border-radius: var(--radius); margin-bottom: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 6px 1px 4px; background: var(--ink-2); vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.pill { display: inline-flex; align-items: center; padding: 3px 10px 3px 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 10px; }
.kpi, .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; display: flex; flex-direction: column; box-shadow: var(--shadow); min-width: 0; }
.kpi .k, .tile .k { font-size: 12px; color: var(--ink-2); }
.kpi .v { font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.tile .v { font-weight: 600; font-size: 14px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 13px; }

/* Filtres */
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.chip { white-space: nowrap; text-decoration: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 600; }
.chip span { color: var(--ink-2); font-weight: 500; margin-left: 2px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.on span { color: inherit; opacity: .7; }
select, input, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; width: 100%; }
.sort select { width: auto; padding: 6px 10px; font-size: 13px; }

/* Grille d'articles */
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 14px 16px; margin-bottom: 12px; }
.card.danger { border-color: var(--bad); }
.item { overflow: hidden; }
.item a { text-decoration: none; display: block; }
.ph { position: relative; aspect-ratio: 3 / 4; background: var(--surface-2); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.age, .st { position: absolute; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.age { top: 6px; left: 6px; color: #fff; }
.age.fresh { background: var(--fresh); } .age.stale { background: var(--stale); } .age.old { background: var(--old); }
.ph .st { bottom: 6px; left: 6px; }
.st { background: var(--surface-2); color: var(--ink); position: static; display: inline-block; }
.ph .st { position: absolute; background: rgb(0 0 0 / .65); color: #fff; }
.st-sold { background: var(--accent) !important; color: var(--accent-ink) !important; }
.body { padding: 8px 10px 10px; }
.body p { margin: 0; }
.t { font-weight: 600; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.meta { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-top: 4px !important; font-size: 12px; }
.row strong { font-size: 14px; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }

/* Fiche article */
.back { display: inline-block; text-decoration: none; color: var(--ink-2); margin-bottom: 10px; font-weight: 600; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px 12px; padding: 0 16px; }
.gallery img { height: min(62vh, 480px); aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius); scroll-snap-align: start; flex: none; background: var(--surface-2); }
.head-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.price { font-size: 22px; font-weight: 750; margin: 6px 0 2px; }
.desc { white-space: pre-wrap; margin: 12px 0 0; }
.spark { width: 100%; height: 80px; display: block; }
.spark polyline { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark .v { stroke: var(--accent); } .spark .f { stroke: var(--warn); }
.legend { font-size: 12px; margin: 6px 0 0; display: flex; gap: 12px; flex-wrap: wrap; }
.lv::before, .lf::before { content: ""; display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; }
.lv::before { background: var(--accent); } .lf::before { background: var(--warn); }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { padding: 8px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }

/* Système */
.btn { font: inherit; font-weight: 650; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stack { display: grid; gap: 8px; margin-top: 10px; }
.howto { padding-left: 20px; font-size: 14px; }
summary { cursor: pointer; font-weight: 600; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; }
td.bad { color: var(--bad); font-weight: 700; }
tr.w td:first-child { box-shadow: inset 3px 0 var(--warn); }
.js { font-size: 12px; font-weight: 700; }
.js-done { color: var(--ok); } .js-failed { color: var(--bad); } .js-pending, .js-taken { color: var(--warn); }

/* Connexion */
body.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { padding: 28px; width: min(92vw, 340px); display: grid; gap: 12px; }
.login-card .brand { font-size: 28px; }
.err { color: var(--bad); font-size: 13px; min-height: 1.2em; }
