:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #1a1c1e;
  --muted: #5f6670;
  --border: #dfe2e6;
  --primary: #008060;
  --primary-hover: #006b50;
  --primary-soft: #e6f4ef;
  --on-primary: #ffffff;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --danger: #c4290f;
  --danger-soft: #fdeae6;
  --info: #1f5fb4;
  --info-soft: #e7f0fb;
  --shadow: 0 1px 2px rgba(20, 24, 28, .06), 0 1px 3px rgba(20, 24, 28, .05);
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --surface: #1b1e21;
    --surface-2: #22262a;
    --text: #eceef0;
    --muted: #9aa2ab;
    --border: #33383d;
    --primary: #2fb88c;
    --primary-hover: #4cc9a0;
    --primary-soft: #16322a;
    --on-primary: #06231a;
    --warn: #f0c36a;
    --warn-soft: #36290e;
    --danger: #ff8a73;
    --danger-soft: #3a1b15;
    --info: #8ab8f5;
    --info-soft: #172a42;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: 88px;
}
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
p { margin: 0 0 .75rem; }
.lead { color: var(--muted); font-size: 1rem; margin-bottom: 1.4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { font: .85em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .08em .35em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* ---------- barre du haut + étapes ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem max(16px, calc((100vw - 1040px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 650; letter-spacing: -.01em; }
.top-actions { display: flex; gap: .3rem; }
.login { max-width: 400px; margin: 8vh auto 0; }
.verify-line { font-size: .86rem; margin-top: .2rem; }
.verify-line.ok { color: var(--primary); font-weight: 600; }
.verify-line.warn { color: var(--warn); }
.verify-line summary { color: var(--warn); font-weight: 600; }
.note-line { color: var(--muted); font-size: .85rem; margin-top: .15rem; }

.stepper {
  display: flex; gap: .25rem; list-style: none; margin: 0 auto; padding: 1.1rem 16px .4rem;
  max-width: 1072px; overflow-x: auto;
}
.step {
  flex: 1 1 0; min-width: 118px; display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border: 0; background: none; color: var(--muted);
  font: inherit; text-align: left; border-radius: 10px; cursor: default;
}
.step .dot {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; font-weight: 650; border: 2px solid var(--border); background: var(--surface);
}
.step.done { color: var(--text); cursor: pointer; }
.step.done:hover { background: var(--surface); }
.step.done .dot { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.step.active { color: var(--text); font-weight: 650; }
.step.active .dot { border-color: var(--primary); color: var(--primary); }

/* ---------- mise en page ---------- */
.view { max-width: 1040px; margin: 0 auto; padding: 1rem 16px 2rem; outline: none; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }

.actionbar {
  position: fixed; inset: auto 0 0 0; z-index: 5;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .8rem max(16px, calc((100vw - 1040px) / 2));
}
.actionbar .left { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.actionbar .info { color: var(--muted); }
.actionbar .right { display: flex; gap: .6rem; align-items: center; }

/* ---------- boutons ---------- */
.btn {
  font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: .5rem; text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }

/* ---------- cartes de boutiques ---------- */
.store {
  text-align: left; font: inherit; color: inherit; cursor: pointer; position: relative;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 1rem; display: flex; flex-direction: column; gap: .25rem; min-height: 118px;
  box-shadow: var(--shadow); transition: border-color .12s, background .12s;
}
.store:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.store.selected { border-color: var(--primary); background: var(--primary-soft); }
.store:disabled { opacity: .55; cursor: not-allowed; }
.store .avatar {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 700;
  background: var(--primary-soft); color: var(--primary); margin-bottom: .35rem;
}
.store.selected .avatar { background: var(--primary); color: var(--on-primary); }
.store .name { font-weight: 650; }
.store .tick {
  position: absolute; top: .8rem; right: .8rem; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); display: grid; place-items: center; font-size: .75rem; color: transparent;
}
.store.selected .tick { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.store.add { border-style: dashed; align-items: center; justify-content: center; color: var(--muted); background: transparent; box-shadow: none; }
.store.add:hover { color: var(--primary); }
.chip { display: inline-block; font-size: .75rem; padding: .05rem .5rem; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }

.empty { text-align: center; padding: 2.5rem 1rem; }
.empty h2 { font-size: 1.2rem; }

/* ---------- liste de produits ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .8rem; }
.toolbar .grow { flex: 1 1 240px; }
input[type="text"], input[type="search"], input[type="password"], select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: .5rem .7rem; width: 100%;
}
select { width: auto; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-scroll { max-height: 56vh; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.selected { background: var(--primary-soft); }
td.chk, th.chk { width: 44px; text-align: center; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.thumb { width: 52px; }
.thumb img, .thumb .ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); display: block; }
.thumb .ph { display: grid; place-items: center; color: var(--muted); font-size: .7rem; }
.title { font-weight: 600; }
.num { text-align: right; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok, .badge.ACTIVE { background: var(--primary-soft); color: var(--primary); }
.badge.warn, .badge.DRAFT { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral, .badge.ARCHIVED { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- récapitulatif ---------- */
.summary { font-size: 1.1rem; line-height: 1.6; }
.summary strong { font-weight: 650; }
.pill { display: inline-block; padding: .05rem .6rem; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 650; margin: .1rem 0; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem 1.4rem; }
.field label.lbl { display: block; font-weight: 600; margin-bottom: .3rem; }
.field select { width: 100%; }
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }
.check input { margin-top: .2rem; flex: none; }
.alert { border-radius: 10px; padding: .7rem .9rem; margin-bottom: .8rem; display: flex; gap: .6rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert strong { font-weight: 650; }
ul.tight { margin: .3rem 0 0; padding-left: 1.2rem; }
.copied-list { columns: 2 280px; margin: .2rem 0 0; padding-left: 1.2rem; }

/* ---------- progression ---------- */
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin: .8rem 0 .4rem; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .3s; }
.result-row { display: grid; grid-template-columns: 110px 1fr auto; gap: .8rem; align-items: start; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: 0; }
.result-row .msg { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.result-row .msg.err { color: var(--danger); }
.result-row .warn-line { color: var(--warn); font-size: .85rem; margin-top: .15rem; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .progress > div { transition: none; } }

/* ---------- dialogue + toast ---------- */
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(10, 12, 14, .5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .4rem; }
.dlg-head h2 { margin: 0; font-size: 1.15rem; }
.dlg-body { padding: .4rem 1.2rem 1.2rem; max-height: 76vh; overflow: auto; }
.form-row { margin-bottom: .85rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: .25rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: .85rem; }
.seg button { font: inherit; border: 0; background: var(--surface); color: var(--muted); padding: .4rem .9rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
details { margin: .4rem 0 1rem; }
summary { cursor: pointer; color: var(--info); font-weight: 600; }
details ol, details ul { margin: .5rem 0 0; padding-left: 1.3rem; }
.store-line { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.store-line:last-of-type { border-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: min(520px, 92vw); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .hide-sm { display: none; }
  .result-row { grid-template-columns: 1fr; gap: .3rem; }
  .actionbar { flex-direction: column; align-items: stretch; gap: .5rem; }
  .actionbar .right { justify-content: flex-end; }
  body { padding-bottom: 130px; }
}
