:root {
  --bg: #0e1013;
  --panel: #161a1f;
  --panel-2: #1d2229;
  --line: #2a3038;
  --text: #e7ebe4;
  --muted: #8d97a3;
  --gb: #9bbc0f;          /* vert ecran Game Boy */
  --gb-dim: #306230;
  --pepite: #ff7a3d;
  --verif: #5aa9ff;
  --risk: #ff5468;
  --ok: #3ccf8e;
  --warn: #f5c044;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line); background: #0b0d10; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; letter-spacing: .3px; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font: 600 10px var(--mono); color: var(--gb); letter-spacing: 1.5px; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; text-decoration: none; color: var(--muted); }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--gb); }
.nav .ico { width: 20px; text-align: center; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
main { padding: 26px clamp(16px, 3vw, 36px) 90px; max-width: 1280px; width: 100%; min-width: 0; }
.grid > *, .shell > * { min-width: 0; }
html, body { overflow-x: hidden; }
h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 22px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }

/* barre mobile */
.tabbar { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #0b0d10ee; backdrop-filter: blur(8px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 10.5px; padding: 4px 0; }
  .tabbar a span { display: block; font-size: 19px; }
  .tabbar a.on { color: var(--gb); }
  main { padding-top: 18px; }
}

/* ---------- elements ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font: 700 24px var(--mono); margin-top: 4px; letter-spacing: -.5px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hot .v { color: var(--pepite); }
.kpi.gb .v { color: var(--gb); }
.two { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.small { font-size: 12.5px; }
.right { text-align: right; }

.btn { border: 1px solid var(--line); background: var(--panel-2); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a424d; }
.btn.primary { background: var(--gb); color: #0e1600; border-color: var(--gb); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--risk); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { background: #0f1216; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9bbc0f55; border-color: var(--gb); }
textarea { width: 100%; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--text); font-size: 14px; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.check { display: inline-flex; gap: 7px; align-items: center; font-size: 14px; cursor: pointer; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: transparent; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 4px; font: 600 11px var(--mono); padding: 2px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.b-pepite { background: #ff7a3d22; color: var(--pepite); }
.b-a_verifier { background: #5aa9ff22; color: var(--verif); }
.b-risque { background: #ff546822; color: var(--risk); }
.b-ecarte { background: #ffffff10; }
.b-ok { background: #3ccf8e22; color: var(--ok); }
.b-partial { background: #f5c04422; color: var(--warn); }
.b-error { background: #ff546822; color: var(--risk); }
.b-running { background: #9bbc0f22; color: var(--gb); }
.src { font: 700 10.5px var(--mono); padding: 2px 6px; border-radius: 5px; color: #0e1013; }
.src-leboncoin { background: #ff8a3d; }
.src-vinted { background: #2bb3b1; }
.src-facebook { background: #6f9cff; }
.src-ebay { background: #f5c044; }

/* cartes annonces */
.cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card.pepite { border-color: #ff7a3d66; box-shadow: 0 0 0 1px #ff7a3d22, 0 8px 30px -18px #ff7a3d; }
.card .ph { aspect-ratio: 16/10; background: #0b0d10 center/cover no-repeat; position: relative; }
.card .ph.nophoto { aspect-ratio: auto; height: 64px; background: repeating-linear-gradient(45deg, #11151a, #11151a 8px, #0d1014 8px, #0d1014 16px); }
.card .ph .tl { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.card .ph .price { position: absolute; bottom: 8px; right: 8px; background: #0e1013e6; padding: 4px 9px; border-radius: 8px; font: 700 16px var(--mono); }
.card .bd { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .t { font-weight: 600; line-height: 1.3; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .t:hover { color: var(--gb); }
.card .meta { font-size: 12.5px; color: var(--muted); }
.econ { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #0f1216; border-radius: 9px; padding: 8px; }
.econ div { text-align: center; }
.econ b { display: block; font: 700 15px var(--mono); }
.econ span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pos { color: var(--ok); } .neg { color: var(--risk); }
.card .acts { display: flex; gap: 6px; padding: 0 14px 14px; flex-wrap: wrap; }
.card.dim { opacity: .55; }

/* tableaux */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--panel); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #ffffff05; }
td.wrap { white-space: normal; min-width: 220px; }
td input, td select { width: 100%; padding: 6px 8px; font-size: 13px; }

/* graphe */
.chart svg { width: 100%; height: 170px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.list { display: flex; flex-direction: column; }
.list .it { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list .it:last-child { border-bottom: 0; }
.list .it .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }

.notice { border: 1px solid #f5c04455; background: #f5c04411; color: #f3dc9a; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; }
.scanbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--gb); box-shadow: 0 0 0 0 #9bbc0f88; animation: p 1.4s infinite; }
@keyframes p { to { box-shadow: 0 0 0 10px #9bbc0f00; } }

/* modale */
.modal-bg { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 20px; }
.modal h3 { margin: 0 0 14px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .box { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; text-align: center; }
.login .screen { background: var(--gb); color: var(--gb-dim); font: 700 13px var(--mono); border-radius: 8px; padding: 18px 10px; margin-bottom: 20px; letter-spacing: 1px; box-shadow: inset 0 0 0 3px #8bac0f; }
.login input { width: 100%; margin-bottom: 12px; text-align: center; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); opacity: 0; transition: .25s; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 60; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.sep { height: 1px; background: var(--line); margin: 16px 0; }
details summary { cursor: pointer; color: var(--muted); }
