/* =========================================================================
   Arbitrage — cockpit sombre "agentic OS"
   ========================================================================= */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0a0a0c;
  --sidebar:   #0d0d10;
  --surface:   #141417;
  --surface-2: #1b1b1f;
  --border:    #2a2a31;
  --border-soft: #1e1e24;
  --text:      #e9e9ec;
  --text-dim:  #a2a2ab;
  --text-mute: #6a6a74;
  --accent:    #f26419;
  --accent-hi: #ff7d38;
  --accent-dim:#f2641926;
  --good:      #46c25a;
  --good-dim:  #46c25a22;
  --danger:    #f7565b;
  --danger-dim:#f7565b1f;
  --shadow:    0 20px 50px -24px rgba(0,0,0,.7);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg:        #f4f5f7;
  --sidebar:   #ffffff;
  --surface:   #ffffff;
  --surface-2: #f1f2f4;
  --border:    #d9dce1;
  --border-soft: #e6e8eb;
  --text:      #1e2228;
  --text-dim:  #5b616b;
  --text-mute: #8a909a;
  --accent:    #e2560f;
  --accent-hi: #f2651c;
  --accent-dim:#e2560f1a;
  --good:      #1c8c3b;
  --good-dim:  #1c8c3b18;
  --danger:    #c62b30;
  --danger-dim:#c62b3016;
  --shadow:    0 18px 44px -26px rgba(20,24,40,.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* l'attribut hidden l'emporte sur .pager{display:flex} etc. */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); }
h1 { font-size: 18px; margin: 0 0 14px; letter-spacing: -.01em; }
h2 { font-size: 14px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
h3 { font-size: 13px; margin: 18px 0 8px; color: var(--text-dim); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 4px; padding: 1px 5px; }
.muted { color: var(--text-mute); font-size: 12px; }
.neg { color: var(--danger); }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 194px 1fr; min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 20px; max-width: 1560px; width: 100%; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border-soft);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 14px 9px; gap: 2px;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 16px; }
.brand-mark { color: var(--accent); font-size: 18px; }
.brand-name { font-weight: 700; font-size: 12px; letter-spacing: .06em; display: flex; flex-direction: column; }
.brand-top { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; white-space: nowrap; }
.brand-ver { white-space: nowrap; font-size: 9px; font-weight: 700; letter-spacing: 0; padding: 1px 5px; flex: none; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); text-transform: none; cursor: help; }
.brand-ver-new { background: var(--accent-dim); color: var(--accent-hi); border-color: var(--accent); }
.brand-sub { font-weight: 500; font-size: 10px; letter-spacing: .04em; color: var(--text-mute); text-transform: none;  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 5px;}

.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 10px; text-transform: uppercase; letter-spacing: .16em;
  color: var(--text-mute); padding: 0 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-dim); font-size: 13px; font-weight: 500; position: relative;
}
.nav-link i { font-style: normal; width: 16px; text-align: center; color: var(--text-mute); font-size: 13px; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent-hi); }
.nav-link.active i { color: var(--accent-hi); }
.nav-link.active::before { content: ""; position: absolute; left: -9px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }

.nav-parent { display: block; }
.nav-toggle { width: 100%; background: transparent; border: none; font: inherit; text-align: left; }
.nav-toggle:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle .chev { margin-left: auto; font-size: 9px; color: var(--text-mute); transition: transform .15s; }
.nav-parent.collapsed .chev { transform: rotate(-90deg); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 4px 12px;
  padding-left: 10px; border-left: 1px solid var(--border); overflow: hidden; }
.nav-parent.collapsed .nav-sub { display: none; }
.nav-link.sub { padding: 6px 10px; font-size: 12.5px; }
.nav-link.sub.active { background: var(--accent-dim); color: var(--accent-hi); }
.nav-link.sub.active::before { display: none; }

.sidebar-foot { margin-top: auto; padding: 14px 8px 4px; display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--border-soft); }
.stat-dot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-mute); }
.stat-dot span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); flex: none; }
.stat-dot.on { color: var(--text-dim); }
.stat-dot.on span { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
}
.topbar-title { font-size: 15px; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px var(--good); }
.pill.off::before { background: var(--text-mute); box-shadow: none; }

/* ---------- Cartes & KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.card + .card, .card-row { margin-top: 16px; }
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 6px 0 18px; }
.kpi { text-align: left; text-decoration: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; color: var(--text); font: inherit; }
button.kpi, a.kpi { cursor: pointer; }
button.kpi:hover, a.kpi:hover { border-color: var(--accent); }
.kpi-val { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-mute); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; white-space: nowrap; }
#grid { font-size: 13px; }
#grid th, #grid td { padding: 11px 12px; vertical-align: middle; }
#grid tbody td { border-bottom: 1px solid var(--border); }
#grid tbody tr:hover { background: rgba(255,255,255,.055); }
:root[data-theme="light"] #grid tbody tr:hover { background: #eef2ff; }
/* Ligne selectionnee (clic) : fond plus sombre, pour retrouver ou on en etait */
#grid tbody tr.row-sel, #cgrid tbody tr.row-sel { background: var(--surface-2); }
#grid tbody tr.row-sel:hover, #cgrid tbody tr.row-sel:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-mute);
  text-transform: uppercase; font-size: 10.5px; letter-spacing: .06em; font-weight: 600; }
table.sortable th[data-type] { cursor: pointer; user-select: none; }
table.sortable th[data-type]::after { content: " ↕"; color: var(--text-mute); font-size: 9px; }
tbody tr:hover { background: rgba(255,255,255,.03); }
:root[data-theme="light"] tbody tr:hover { background: #f3f6ff; }
tr:last-child td { border-bottom: none; }
/* Bonne opportunite : simple barre verte a gauche (pas de fond colore -> lignes uniformes) */
tr.row-good td:first-child { box-shadow: inset 3px 0 0 var(--good); }
tr.row-a_acheter td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tr.row-achete td, tr.row-ignore td { opacity: .4; }
.prodname { white-space: normal; min-width: 180px; max-width: 300px; }
.pos { color: var(--good); }

/* ---- Pagination ---- */
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 12px; }
.pager #pg-pages { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.pager label { display: flex; align-items: center; gap: 6px; }
.pager select { padding: 5px 8px; }
.pg-btn {
  min-width: 30px; padding: 5px 8px; font-size: 12px; border-radius: 7px;
  background: transparent; color: var(--text-dim); border: 1px solid var(--border); cursor: pointer;
}
.pg-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-hi); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg-btn:disabled { opacity: .35; cursor: default; }
.pg-dots { color: var(--text-mute); padding: 0 2px; }

/* ---- Tableau groupé Fournisseur / Amazon / Rentabilité ---- */
table.grouped th.num, table.grouped td.num { text-align: right; }
tr.grp th { background: var(--surface-2); color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .14em; font-size: 10px; font-weight: 700; text-align: center;
  border-bottom: 1px solid var(--border); padding: 8px; }
tr.grp th:nth-child(2), tr.grp th:nth-child(3), tr.grp th:nth-child(4) { border-left: 1px solid var(--border); }
#grid thead tr:last-child th { top: 31px; background: var(--surface); }
/* filets verticaux discrets entre les 3 groupes de colonnes */
#grid tbody td:nth-child(4), #grid tbody td:nth-child(12), #grid tbody td:nth-child(16),
#grid thead tr:last-child th:nth-child(4), #grid thead tr:last-child th:nth-child(12),
#grid thead tr:last-child th:nth-child(16) { border-left: 1px solid var(--border-soft); }
td.thumb { width: 48px; padding: 6px 8px; }
td.thumb img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px;
  background: #fff; display: block; padding: 2px; }
td.vendors { font-size: 11.5px; line-height: 1.5; white-space: nowrap; text-align: center; }
td.vendors .v-wrap { display: inline-grid; grid-template-columns: 1.8em auto; gap: 2px 5px; text-align: left; }
td.vendors .v-wrap b { text-align: right; font-weight: 600; }
td.vendors small { color: var(--text-mute); }
#grid .prodname { max-width: 150px; min-width: 120px; }
#grid .prodname a { color: var(--text); font-weight: 550; }
#grid .prodname a:hover { color: var(--accent-hi); }
/* titre produit : une seule ligne, "…" au bout, texte complet au survol (title) */
#grid .prodname .pname {
  display: block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#grid .prodname .muted {
  display: block; margin-top: 2px; font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#grid td.num strong { font-size: 13px; }

.auth { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; white-space: nowrap; }
.auth-ok { background: var(--good-dim); color: var(--good); }
.auth-warn { background: #f2641926; color: var(--accent-hi); }
.auth-bad { background: var(--danger-dim); color: var(--danger); }

/* ---- Pastilles "Amazon" (Oui/Non) et "Autorisation" ---- */
.pill-amz { display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 11px;
  border-radius: 999px; letter-spacing: .02em; }
.pill-amz-yes { background: var(--accent); color: #fff; }
.pill-amz-no  { background: #17181d; color: #d9dbe2; }
:root[data-theme="light"] .pill-amz-no { background: #1e2228; color: #fff; }
.pill-amz-unk { background: var(--surface-2); color: var(--text-mute); }

.pill-auth { display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 4px 11px; border-radius: 999px; white-space: nowrap;
  text-decoration: none; border: 1px solid transparent; transition: background .12s, border-color .12s;
  min-width: 96px; box-sizing: border-box; }
a.pill-auth:hover { filter: brightness(1.12); }
button.pill-auth { font: inherit; cursor: pointer; }
button.pill-auth:hover { filter: brightness(1.12); }
.pill-auth-check { background: #1b2b4d; color: #9cc0ff; }
:root[data-theme="light"] .pill-auth-check { background: #e8f0fe; color: #1a56db; }
.pill-auth-ok   { background: var(--good-dim); color: var(--good); }
.pill-auth-ok:hover { background: color-mix(in srgb, var(--good) 22%, transparent); border-color: var(--good); color: var(--good); filter: none; }
.pill-auth-warn { background: #f2641926; color: var(--accent-hi); }
.pill-auth-warn:hover { background: #f2641945; border-color: var(--accent-hi); color: var(--accent-hi); filter: none; }
.pill-auth-bad  { background: var(--danger-dim); color: var(--danger); }
.pill-auth-bad:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); border-color: var(--danger); color: var(--danger); filter: none; }

/* ---- Petite icone "pico" (ouvrir sur Amazon/Google/Keepa), reutilisable ---- */
.ap-pico { width: 26px; height: 26px; flex: none; display: inline-flex; align-items: center;
  justify-content: center; border: 1px solid var(--border-soft); border-radius: 7px;
  background: var(--surface-2); color: inherit; font-size: 13px; font-weight: 700;
  text-decoration: none; line-height: 1; vertical-align: middle; }
.ap-pico:hover { border-color: var(--border); filter: brightness(1.25); }
/* "a" Amazon : plus grasse que G/graphique, mais meme fond que les autres
   icones dans chaque theme (blanc en clair, sombre en sombre). */
.ap-pico.a { font-size: 16px; font-weight: 800; }
:root[data-theme="light"] .ap-pico.a { background: #fff; color: #14161a; border-color: var(--border-soft); }
.ap-pico.a:hover { color: var(--accent-hi); filter: none; }

/* ---- Menu "⋯" d'une ligne ---- */
.rowmenu-panel { min-width: 232px; padding: 6px; gap: 0; max-height: 80vh; overflow-y: auto; }
.rowmenu-panel form { display: block; margin: 0; }
.rm-item {
  display: flex; align-items: center; width: 100%; gap: 4px;
  padding: 8px 10px; border: none; background: transparent; border-radius: 8px;
  color: var(--text-dim); font-size: 12.5px; font-weight: 500;
  text-align: left; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.rm-item:hover { background: var(--surface-2); color: var(--text); border: none; }
.rm-badge { margin-left: auto; background: var(--accent); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700; padding: 0 6px; line-height: 1.6; }
.rm-sep { height: 1px; background: var(--border-soft); margin: 5px 2px; }
.rm-statusrow select { width: 100%; font-size: 12px; padding: 6px 8px; margin: 2px 0; }
.rm-danger { color: var(--danger); }
.rm-danger:hover { background: var(--danger-dim); color: var(--danger); }

/* ---- Fenêtre "Détails du calcul" ---- */
.cmodal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; }
.cmodal[hidden] { display: none !important; }
.cmodal-box { position: relative; width: min(460px, 96vw); max-height: 84vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 20px 22px; }
.cmodal-box h3 { margin: 0 0 2px; font-size: 16px; color: var(--text); }
.cmodal-box #calc-modal-sub { margin: 0 0 6px; font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmodal-x { position: absolute; top: 12px; right: 12px; border: none; background: transparent;
  color: var(--text-mute); font-size: 15px; padding: 4px 7px; cursor: pointer; }
.cmodal-x:hover { color: var(--danger); background: transparent; border: none; }

.calc-dtable { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px;
  border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; }
.calc-dtable td { padding: 3px 14px; color: var(--text-dim); }
.calc-dtable td.r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.calc-dtable tr.h td { font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-mute); padding-top: 11px; }
.calc-dtable tr.b td { color: var(--text); font-weight: 700; padding-bottom: 7px;
  border-bottom: 1px solid var(--border-soft); }
.calc-dtable td.pos { color: var(--good); }
.calc-dtable td.neg { color: var(--danger); }
.calc-dtable tr.total td { font-weight: 700; font-size: 13.5px; padding: 11px 14px;
  background: var(--accent-dim); color: var(--text); }

/* ---- Assistant d'import de catalogue ---- */
.iwiz { position: fixed; inset: 0; z-index: 72; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; }
.iwiz[hidden] { display: none !important; }
.iwiz-box { position: relative; width: min(680px, 96vw); max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 22px 24px 18px; }
.iwiz-x { position: absolute; top: 14px; right: 14px; border: none; background: transparent;
  color: var(--text-mute); font-size: 15px; padding: 4px 7px; cursor: pointer; }
.iwiz-x:hover { color: var(--danger); background: transparent; border: none; }

.iwiz-steps { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0 20px; }
.iwiz-step { display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-mute); font-size: 12px; font-weight: 700;
  flex: none; position: relative; }
.iwiz-step small { position: absolute; top: 34px; font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.iwiz-step.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.iwiz-bar { width: 60px; height: 2px; background: var(--border); flex: none; }

.iwiz-pane[hidden] { display: none !important; }
.iwiz-pane h3 { margin: 0 0 4px; font-size: 16px; color: var(--text); }
.iwiz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 8px 0 4px; }
.iwiz-fld { display: flex; flex-direction: column; gap: 5px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); }
.iwiz-fld input, .iwiz-fld select { font-size: 13px; padding: 8px 10px; }
.iwiz-fld .req { color: var(--danger); }
.iwiz-sub { margin: 16px 0 8px; font-size: 12.5px; color: var(--text-dim); }

.iwiz-drop { display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 150px; margin-top: 12px; border: 2px dashed var(--border); border-radius: 14px;
  color: var(--text-mute); font-size: 13px; line-height: 1.9; cursor: pointer; }
.iwiz-drop:hover, .iwiz-drop.is-over { border-color: var(--accent); color: var(--text-dim);
  background: var(--accent-dim); }
.iwiz-drop small { font-size: 11px; }
.iwiz-fileinfo { margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft); font-size: 12.5px; }

.iwiz-preview { max-height: 320px; overflow: auto; border: 1px solid var(--border-soft); border-radius: 10px; }
.iwiz-ptable { width: 100%; border-collapse: collapse; font-size: 12px; }
.iwiz-ptable td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft);
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.iwiz-ptable td.rc { width: 30px; text-align: center; }
.iwiz-ptable tr { cursor: pointer; }
.iwiz-ptable tr:hover td { background: var(--surface-2); }
.iwiz-ptable tr.sel td { background: var(--accent-dim); color: var(--text); font-weight: 600; }

.iwiz-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px;
  padding-top: 14px; border-top: 1px solid var(--border-soft); }
.iwiz-nav #iwiz-back[hidden] { display: none; }
.iwiz-nav #iwiz-next { margin-left: auto; }

@media (max-width: 620px) { .iwiz-grid { grid-template-columns: 1fr; } }

/* ---- Vue catalogue importé ---- */
.cv-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border-soft); }
.cv-flag { border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.25); flex: none; }
.cv-title { display: flex; flex-direction: column; }
.cv-title .muted { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.cv-title strong { font-size: 15px; }
.cv-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 16px; }
.cv-grid .field { min-width: 0; }
.cv-grid .field select.op {
  border: none; background: transparent; padding: 0 14px 0 0; margin: 0;
  font-weight: 600; color: var(--text-mute); min-width: 0; width: auto; font-size: 12px;
  background-position: right 2px center; background-size: 4px 4px, 4px 4px;
}
.cv-grid .field select.op:focus { box-shadow: none; }
.cv-sortfld { min-width: 0; }
.cv-sortfld select { border: none; background: transparent; padding: 0 18px 0 0; }
.cv-sortfld select:focus { box-shadow: none; }
.cv-excl { margin-top: 14px; }
.cv-excl legend { font-size: 10px; }
.cv-excl { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.cv-excl .chk { font-size: 12.5px; color: var(--text-dim); text-transform: none; letter-spacing: 0; }

#cgrid { font-size: 13px; }
#cgrid th, #cgrid td { padding: 11px 12px; vertical-align: middle; }
#cgrid tbody td { border-bottom: 1px solid var(--border); }
#cgrid tbody tr:hover { background: rgba(255,255,255,.055); }
:root[data-theme="light"] #cgrid tbody tr:hover { background: #eef2ff; }
#cgrid thead tr:last-child th { top: 31px; background: var(--surface); }
#cgrid .prodname { max-width: 160px; }
#cgrid .prodname a, #cgrid .prodname .pname { color: var(--text); font-weight: 550;
  display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#cgrid tbody td:nth-child(3), #cgrid tbody td:nth-child(11), #cgrid tbody td:nth-child(15),
#cgrid thead tr:last-child th:nth-child(3), #cgrid thead tr:last-child th:nth-child(11),
#cgrid thead tr:last-child th:nth-child(15) { border-left: 1px solid var(--border-soft); }
.cv-copy { color: var(--text-dim); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; }
.haz-tag { color: var(--danger); font-size: 12px; }

@media (max-width: 1100px) { .cv-grid { grid-template-columns: repeat(2, 1fr); } }

.rowmenu { position: relative; }
.rowmenu > summary { list-style: none; cursor: pointer; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 7px; color: var(--text-dim); display: inline-block; }
.rowmenu > summary::-webkit-details-marker { display: none; }
.rowmenu[open] > summary { border-color: var(--accent); color: var(--accent-hi); }
.rowmenu-panel { position: absolute; right: 0; z-index: 30; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 230px; }
.rowmenu-panel form { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; }
.rowmenu-panel input, .rowmenu-panel select { font-size: 12px; padding: 4px 6px; }

/* ---------- Formulaires ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px;
}
input::placeholder { color: var(--text-mute); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { width: 100%; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
select { appearance: none; padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-mute) 50%),
                    linear-gradient(135deg, var(--text-mute) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
/* liste déroulante native : options lisibles quel que soit le rendu du navigateur.
   Valeurs en dur (certaines versions de Chrome/Windows n'appliquent pas var() ici). */
select option, select optgroup {
  background-color: #17171b !important;
  color: #e9e9ec !important;
}
:root[data-theme="light"] select option,
:root[data-theme="light"] select optgroup {
  background-color: #ffffff !important;
  color: #1e2228 !important;
}
input, select, textarea, button { color-scheme: inherit; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 14px;
}
.filters label { display: flex; flex-direction: column; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-mute); gap: 5px; }
.filters label.chk { flex-direction: row; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.filters input[type=number], .filters input[type=search] { width: 120px; }

/* ---- Barre de recherche (Recherche fournisseurs) — calquée sur la maquette ---- */
.searchbar { margin-bottom: 16px; padding: 20px 22px; }
.sb-grid { display: flex; flex-wrap: wrap; align-items: stretch; gap: 16px; }
.sb-group { display: flex; flex-direction: column; gap: 12px; justify-content: center; }
.sb-group.sb-right { margin-left: auto; }
.sb-sep { width: 1px; background: var(--border-soft); align-self: stretch; }

/* champ = un bloc bordé avec label + opérateur + input sans bordure + unité */
.field {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); padding: 9px 12px;
  font-size: 12.5px; color: var(--text-dim); min-width: 210px;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.field .f-label { color: var(--text-dim); }
.field .op { color: var(--text-mute); font-weight: 600; }
.field .unit { margin-left: auto; color: var(--text-mute); min-width: 12px; text-align: right; }
.field input { flex: 1 1 auto; min-width: 20px; width: auto;
  border: none; background: transparent; padding: 0; color: var(--text); font-size: 12.5px; }
.field input:focus { outline: none; box-shadow: none; }
.field input::placeholder { color: var(--text-mute); }

.field.sort-field { min-width: 0; }
.field.sort-field select { border: none; background: transparent; padding: 0 18px 0 0; min-width: 90px; }
.field.sort-field select:focus { box-shadow: none; }
#f-sortdir { padding: 3px 7px; font-size: 11px; }

.sb-group > select {                 /* Marketplace / Fournisseur */
  min-width: 190px; padding: 10px 30px 10px 12px; border-radius: 10px;
  background-color: var(--surface-2); font-size: 12.5px;
}

/* Sélecteur de marketplace custom (drapeaux dans la liste) */
.mktsel { position: relative; min-width: 190px; }
.mktsel-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-soft);
  background: var(--surface-2); color: inherit; font-size: 12.5px; cursor: pointer; text-align: left;
}
.mktsel-btn:hover { border-color: var(--border); }
.mktsel-cur { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mktsel-cur svg { flex: none; }
.mktsel-chev { opacity: .6; font-size: 10px; }
.mktsel-list {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0; margin: 0;
  list-style: none; padding: 6px; border-radius: 10px;
  background: var(--surface-1, var(--surface-2)); border: 1px solid var(--border-soft);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .4);
}
.mktsel-list[hidden] { display: none; }
.mktsel-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; font-size: 13px; cursor: pointer;
}
.mktsel-list li:hover { background: var(--surface-2); }
.mktsel-list li.sel { background: var(--surface-2); font-weight: 600; }
.mktsel-flag { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); flex: none; }

.sb-adv {
  display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft);
}
.sb-adv[hidden] { display: none !important; }   /* replié tant qu'on ne clique pas "Filtres avancés" */
.sb-adv > select { min-width: 160px; padding: 8px 28px 8px 12px; border-radius: 10px; font-size: 12.5px; }
.sb-adv .field { min-width: 0; }
.sb-adv .chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }

.sb-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft);
  justify-content: flex-end;
}
.sb-actions #row-count { margin-right: auto; }
#f-presets { min-width: 210px; padding: 9px 30px 9px 14px; border-radius: 10px; font-size: 12.5px; }
.reset-btn { display: inline-flex; align-items: center; gap: 6px; }
button.neutral, .btn.neutral {
  background: var(--text-mute); border-color: var(--text-mute); color: #fff;
}
button.neutral:hover { background: var(--text-dim); border-color: var(--text-dim); color: #fff; }

.sb-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sb-banner form { margin: 0; }
.scan-banner { flex-direction: column; align-items: stretch; gap: 8px; }
.scan-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
#scan-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }

@media (max-width: 1100px) {
  .sb-group.sb-right { margin-left: 0; }
  .field, .sb-group > select, #f-presets { min-width: 0; width: 100%; }
}

form.stack { max-width: 640px; }
form.stack > label, form.stack fieldset { display: block; margin-bottom: 16px; }
form.stack label { font-size: 12.5px; color: var(--text-dim); }
form.stack label.chk { display: flex; align-items: center; gap: 8px; }
form.stack input:not([type=checkbox]), form.stack textarea, form.stack select { width: 100%; margin-top: 5px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
legend { font-weight: 600; padding: 0 6px; color: var(--text); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 label { margin: 0; }

/* ---------- Boutons ---------- */
button, .btn {
  font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; padding: 7px 12px; display: inline-block; text-decoration: none; line-height: 1.3;
}
.btn:hover { background: var(--accent-hi); border-color: var(--accent-hi); color: #fff; }
button.ghost, .btn.ghost, table button, .actions button, .statusform button, form.enrich button {
  background: transparent; color: var(--text-dim); border-color: var(--border);
}
button.ghost:hover, .btn.ghost:hover, table button:hover, .actions button:hover,
.statusform button:hover, form.enrich button:hover { border-color: var(--accent); color: var(--accent-hi); }
button.danger, .actions button.danger { color: var(--danger); border-color: transparent; background: transparent; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions form { display: flex; gap: 4px; margin: 0; }
.actions form.enrich { flex-wrap: wrap; max-width: 190px; }
.actions form.enrich input { font-size: 11px; padding: 3px 5px; width: 58px; }
.actions form.enrich input[name="asin"] { width: 80px; }
.statusform { display: flex; gap: 4px; align-items: center; margin: 0; }
.statusform select, .statusform input { font-size: 11.5px; padding: 3px 5px; }

/* ---------- Divers ---------- */
.badge { display: inline-block; min-width: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10.5px; text-align: center; line-height: 1.5; font-weight: 600; }
.flash { padding: 10px 13px; border-radius: 10px; margin-bottom: 10px; font-size: 12.5px; border: 1px solid transparent; }
.flash-ok { background: var(--good-dim); border-color: color-mix(in srgb, var(--good) 40%, transparent); color: var(--text); }
.flash-error { background: var(--danger-dim); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--text); }

.test-output { background: #08080a; color: #d6d6db; padding: 14px; border-radius: 10px; border: 1px solid var(--border);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.55;
  white-space: pre-wrap; overflow: auto; max-height: 320px; margin-top: 12px; }
.hidden { display: none; }
.empty-state { text-align: center; padding: 52px 28px; }
.empty-state h1 { margin-bottom: 10px; }
.empty-state p { max-width: 60ch; margin: 0 auto 14px; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
ul.muted { padding-left: 18px; }
.demo-note { margin: 8px 0 0; font-size: 12px; }
.demo-note.flash { color: var(--danger); font-weight: 600; }

/* ---------- Palette de commandes ---------- */
.palette { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette[hidden] { display: none !important; }
.palette-box { position: relative; width: min(560px, 92vw); background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.palette-x { position: absolute; top: 9px; right: 9px; border: none; background: transparent;
  font-size: 14px; color: var(--text-mute); padding: 4px 6px; }
.palette-x:hover { color: var(--danger); background: transparent; border-color: transparent; }
#palette-input { width: 100%; border: none; border-bottom: 1px solid var(--border); background: transparent;
  padding: 15px 40px 15px 16px; font-size: 14px; border-radius: 0; }
#palette-input:focus { outline: none; box-shadow: none; }
#palette-list { list-style: none; margin: 0; padding: 6px; max-height: 46vh; overflow: auto; }
#palette-list li { padding: 9px 11px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text-dim); }
#palette-list li.sel, #palette-list li:hover { background: var(--accent-dim); color: var(--accent-hi); }
.palette-hint { padding: 8px 16px; border-top: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 4px;
    overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border-soft); padding: 8px 10px; }
  .brand, .nav-group-title, .sidebar-foot { display: none; }
  .nav-group { margin: 0; display: flex; }
  .nav-link.active::before { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.risk { display:inline-block; min-width:28px; padding:1px 7px; border-radius:999px; font-size:11px; font-weight:700; text-align:center; cursor:help; }
.risk-faible { background: var(--good-dim); color: var(--good); }
.risk-moyen { background: var(--accent-dim); color: var(--accent-hi); }
.risk-eleve { background: var(--danger-dim); color: var(--danger); }
.hist-svg { width:100%; height:auto; display:block; }
.hist-grid { stroke: var(--border); stroke-width:1; }
.hist-tx { font-size:10px; fill: var(--text-mute); }
.hist-tx-b { fill:#6aa9ff; }
.hist-line { fill:none; stroke-width:2; stroke-linejoin:round; }
path.hist-price { stroke: var(--accent); } path.hist-bsr { stroke:#6aa9ff; } path.hist-sup { stroke: var(--good); stroke-dasharray:5 4; }
circle.hist-price { fill: var(--accent); } circle.hist-bsr { fill:#6aa9ff; } circle.hist-sup { fill: var(--good); }
.hist-legend { display:flex; flex-wrap:wrap; gap:6px 16px; font-size:12px; margin-bottom:6px; color: var(--text-dim); }
.hist-legend i { display:inline-block; width:14px; height:3px; margin-right:6px; vertical-align:middle; border-radius:2px; }
.hist-legend i.hist-price { background: var(--accent); } .hist-legend i.hist-bsr { background:#6aa9ff; } .hist-legend i.hist-sup { background: var(--good); }
.lot-badge { display:inline-block; margin-left:5px; padding:0 6px; border-radius:999px; font-size:10px; font-weight:700; background:var(--accent-dim); color:var(--accent-hi); vertical-align:middle; white-space:nowrap; }
.lot-badge-unk { background:var(--surface-2); color:var(--text-mute); }
.seen-age { display:block; font-size:10px; font-weight:400; color:var(--text-mute); white-space:nowrap; }
.seen-age.seen-old { color:#f6b45b; font-weight:700; }
.mkt-tag { display:inline-block; margin-left:5px; padding:0 5px; border-radius:4px; font-size:9px; font-weight:700; background:#3a2a12; color:#f6b45b; vertical-align:middle; }

/* ---- Barre "Filtres actifs" ---- */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; }
.active-filters[hidden] { display: none; }
.af-label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--text-mute); margin-right: 2px; }
.active-filters .chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px 5px 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-dim); font-size: 12px; font-weight: 500; cursor: pointer; line-height: 1.2;
}
.active-filters .chip:hover { border-color: var(--accent); color: var(--text); }
.chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; background: var(--border);
  color: var(--text-dim); font-size: 12px; line-height: 1;
}
.active-filters .chip:hover .chip-x { background: var(--accent); color: #fff; }
.af-clear {
  background: transparent; border: none; color: var(--text-mute); font-size: 12px;
  text-decoration: underline; padding: 4px 6px; cursor: pointer;
}
.af-clear:hover { color: var(--danger); background: transparent; border: none; }

/* ---- Page de connexion ---- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px;
  box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700;
  letter-spacing: .14em; font-size: 13px; margin-bottom: 22px; }
.login-brand .brand-mark { color: var(--accent); font-size: 20px; }
.login-brand small { display: block; font-weight: 500; font-size: 10px;
  letter-spacing: .04em; color: var(--text-mute); text-transform: none; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.login-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 13px; }
.login-error { background: var(--danger-dim);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--text); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; margin-bottom: 16px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); }
.login-form input:not([type=checkbox]) { padding: 10px 12px; font-size: 13.5px; }
.login-remember { flex-direction: row !important; align-items: center; gap: 8px !important;
  text-transform: none !important; letter-spacing: 0 !important; font-size: 12.5px !important;
  color: var(--text-dim) !important; }
.login-btn { width: 100%; padding: 11px; font-size: 13.5px; margin-top: 4px; }
.login-foot { font-size: 11px; }
