:root {
  --bg: #f4f4f1; --card: #fff; --fg: #1d1d1b; --muted: #6b6b66; --line: #e2e2dc;
  --accent: #0b7a75; --accent-fg: #fff; --ok: #2e7d32; --warn: #b3261e; --orange: #b26a00;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121212; --card: #1e1e1e; --fg: #ededea; --muted: #a2a29c; --line: #303030;
    --accent: #3fb8b0; --accent-fg: #082221; --ok: #7bc47f; --warn: #ff8a80; --orange: #ffb74d; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 -apple-system, system-ui, sans-serif; padding-bottom: calc(64px + var(--safe-b)); }
.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
h1 { font-size: 19px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
main { padding: 8px 16px; max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.muted { color: var(--muted); font-size: 14px; }
.warn { color: var(--warn); }
button { font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; min-height: 44px; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--warn); }
button:disabled { opacity: .5; }
.round { width: 46px; height: 46px; border-radius: 50%; font-size: 22px; padding: 0; flex: none; }
.round.spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
input[type=password], input[type=search], input[type=text], select { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); margin: 6px 0 10px; }
select { width: auto; margin: 0 6px; }
.line { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.line input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.todo { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.todo:first-child { border-top: none; }
.todo .ic { font-size: 20px; width: 26px; text-align: center; flex: none; }
.todo .tx { flex: 1; min-width: 0; }
.todo .tx b { display: block; }
.todo .tx small { color: var(--muted); display: block; overflow-wrap: anywhere; }
.todo a { color: var(--accent); }
.todo button { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 13px; color: var(--muted); }
.log { font-size: 14px; white-space: pre-line; color: var(--muted); overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
td, th { padding: 8px 4px; border-top: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: 13px; border-top: none; }
td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sale { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.sale:first-child { border-top: none; }
.sale .tx { flex: 1; min-width: 0; }
.sale .tx small { color: var(--muted); display: block; }
.sale select { margin: 0; padding: 6px 8px; font-size: 14px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.chips button { min-height: 34px; padding: 4px 12px; border-radius: 17px; font-size: 14px; white-space: nowrap; }
.chips button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.items { list-style: none; padding: 0; margin: 8px 0 0; }
.items li { display: flex; gap: 8px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.items .id { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; font-size: 14px; }
.items .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b { font-size: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--muted); white-space: nowrap; text-decoration: none; }
.b.on { border-color: var(--ok); color: var(--ok); }
.b.sold { border-color: var(--warn); color: var(--warn); }
.b.off { opacity: .5; text-decoration: line-through; }
.b.todo { border-color: var(--orange); color: var(--orange); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 3; }
.tabs button { flex: 1; border: none; border-radius: 0; background: none; font-size: 14px; color: var(--muted); min-height: 54px; }
.tabs button.on { color: var(--accent); font-weight: 600; }
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(70px + var(--safe-b)); background: var(--fg); color: var(--bg); border-radius: 12px; padding: 12px 14px; z-index: 4; font-size: 15px; }
code { font-size: 13px; }
a { color: var(--accent); }

/* Préparer une annonce (titre/prix/description à copier, photos à enregistrer) */
.items li.row { cursor: pointer; }
.items li.holder { display: block; padding: 0; border-top: none; }
.detail { margin: 0 0 8px 0; padding: 10px 10px 12px; border-left: 3px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--bg); }
.detail .chips { margin-bottom: 8px; }
.field { margin: 0 0 10px; }
.field .flabel { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.field .flabel span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field .flabel button { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.field .fval { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 4px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumbs .hint { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.detail .close { width: 100%; margin-top: 4px; }

/* Virements aux bénéficiaires */
.payouts { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.payoutRow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; padding: 6px 0; }
.payoutRow button { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.payoutHist { font-size: 13px; margin: 0 0 6px; }
.payoutHist summary { color: var(--muted); }
.payoutLine { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 0 4px 12px; }
.payoutLine button { min-height: 28px; padding: 2px 8px; font-size: 12px; color: var(--warn); }
.payoutForm { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; padding: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.payoutForm input { font: inherit; font-size: 14px; padding: 6px 8px; margin: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: auto; }
.payoutForm input[type=number] { width: 90px; }
.payoutForm button { min-height: 36px; padding: 5px 10px; font-size: 13px; }
