/* ============================================================
   Centrale Récréaclub — Design System Premium
   Inspiré Stripe / Linear / Notion / Vercel
   Palette claire & sobre, ombres douces, typographie Inter,
   micro-animations, hiérarchie aérée.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* === Surfaces === */
  --bg-page:    #f7f8fb;
  --bg-card:    #ffffff;
  --surface:    #ffffff;
  --surface-2:  #f9fafc;
  --surface-3:  #f3f5f9;
  --bg:         #0f172a;        /* compat */
  --bg-soft:    #1e293b;        /* compat */

  /* === Text === */
  --text:        #0b1220;
  --text-strong: #050816;
  --text-soft:   #4b5563;
  --text-muted:  #8b94a7;

  /* === Borders / rings === */
  --border:        #eaecf2;
  --border-strong: #d8dce5;
  --ring:          rgba(99, 102, 241, 0.18);

  /* === Brand : indigo premium → violet === */
  --primary:       #4f46e5;
  --primary-dark:  #3f37c9;
  --primary-soft:  #eef0ff;
  --accent:        #8b5cf6;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a855f7 100%);

  /* === Sémantique === */
  --success:      #059669;
  --success-soft: #ecfdf5;
  --danger:       #dc2626;
  --danger-soft:  #fef2f2;
  --warning:      #d97706;
  --warning-soft: #fffbeb;
  --info:         #0284c7;
  --info-soft:    #f0f9ff;

  /* === Ombres feuilletées (subtiles, premium) === */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow:    0 2px 4px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 8px rgba(15, 23, 42, 0.05), 0 10px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 24px -8px rgba(15, 23, 42, 0.12), 0 24px 48px -12px rgba(15, 23, 42, 0.18);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.22), 0 48px 96px -24px rgba(15, 23, 42, 0.28);

  /* === Rayons === */
  --radius-xs: 6px;
  --radius:    10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* === Transitions === */
  --t-fast: 120ms cubic-bezier(.4,0,.2,1);
  --t-base: 180ms cubic-bezier(.4,0,.2,1);
  --t-slow: 280ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

/* Subtil halo de fond pour donner de la profondeur */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,0.06), transparent 60%),
    radial-gradient(900px 500px at 110% 0%,  rgba(139,92,246,0.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary-dark); text-decoration: none; }

::selection { background: rgba(99,102,241,0.22); color: var(--text-strong); }

/* Scrollbar fine */
* { scrollbar-width: thin; scrollbar-color: #cbd2dd transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #cbd2dd; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #a8b2c2; background-clip: padding-box; border: 2px solid transparent; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ============================================================
   Topbar — premium glass + nav clean
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(15,23,42,0.06);
  color: var(--text);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 1px 0 rgba(15,23,42,0.02);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  flex-shrink: 0;
}
.topbar .brand .brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.topbar .brand .brand-name small {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.topbar .brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 6px 16px -4px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  letter-spacing: -0.02em;
}
.topbar .brand .logo svg { width: 20px; height: 20px; }

.topbar nav {
  display: flex;
  gap: 2px;
  flex: 1;
  margin-left: 12px;
}
.topbar nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  transition: all var(--t-fast);
  position: relative;
  white-space: nowrap;
}
.topbar nav a:hover {
  color: var(--text-strong);
  background: var(--surface-3);
  text-decoration: none;
}
.topbar nav a.active {
  color: var(--primary-dark);
  background: var(--primary-soft);
}
.topbar nav a .nav-ico { font-size: 14px; opacity: 0.85; }

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  flex-shrink: 0;
}
.topbar .user-info .who {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  line-height: 1.25;
}
.topbar .user-info .who .name { font-weight: 600; color: var(--text-strong); }
.topbar .user-info .who .role {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.topbar .user-info .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 10px -2px rgba(99,102,241,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.topbar .user-info .actions { display: flex; gap: 6px; }
.topbar .user-info .actions button {
  background: var(--surface);
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all var(--t-fast);
  font-family: inherit;
}
.topbar .user-info .actions button:hover {
  background: var(--surface-3);
  color: var(--text-strong);
  border-color: var(--border-strong);
}
.topbar .user-info .actions button.danger:hover {
  color: var(--danger);
  border-color: rgba(220,38,38,0.3);
  background: var(--danger-soft);
}

/* ============================================================
   Layout
   ============================================================ */
.main {
  flex: 1;
  padding: 32px 28px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px 0;
  color: var(--text-strong);
}
.page-subtitle {
  color: var(--text-soft);
  margin: 0 0 28px 0;
  font-size: 14px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  transition: box-shadow var(--t-base), border-color var(--t-base);
  animation: fadeUp 360ms cubic-bezier(.2,.6,.2,1) both;
}
.card:hover { box-shadow: var(--shadow); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title {
  font-size: 15.5px;
  font-weight: 600;
  margin: 0;
  color: var(--text-strong);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.card-subtitle { color: var(--text-soft); font-size: 13px; margin: 4px 0 0 0; }

/* ============================================================
   KPI grid — premium avec icône + tendance
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
  animation: fadeUp 360ms cubic-bezier(.2,.6,.2,1) both;
}
.kpi::before {
  /* halo coloré subtil dans le coin haut-droit */
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, var(--primary-soft) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.kpi:hover::before { opacity: 1; }

.kpi .kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.kpi .label, .kpi .kpi-label {
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.kpi .kpi-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}
.kpi .kpi-icon.green { background: var(--success-soft); color: var(--success); }
.kpi .kpi-icon.red   { background: var(--danger-soft);  color: var(--danger); }
.kpi .kpi-icon.amber { background: var(--warning-soft); color: var(--warning); }
.kpi .kpi-icon.blue  { background: var(--info-soft);    color: var(--info); }

.kpi .value, .kpi .kpi-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 2px;
  color: var(--text-strong);
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi .hint, .kpi .kpi-sub, .kpi .kpi-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi .trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.kpi .trend.up    { color: var(--success); background: var(--success-soft); }
.kpi .trend.down  { color: var(--danger);  background: var(--danger-soft); }
.kpi .trend.flat  { color: var(--text-muted); background: var(--surface-3); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--surface);
  color: var(--text-strong);
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px -2px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 6px 16px -2px rgba(99,102,241,0.55), inset 0 1px 0 rgba(255,255,255,0.18); }
.btn-primary:active { filter: brightness(0.96); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 3px 8px -2px rgba(220,38,38,0.4);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; box-shadow: 0 4px 10px -2px rgba(220,38,38,0.5); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text-strong); transform: none; }

.btn-secondary {
  background: var(--surface-3);
  color: var(--text-strong);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e9edf3; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 20px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============================================================
   Forms
   ============================================================ */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-row input:hover, .form-row select:hover, .form-row textarea:hover { border-color: var(--border-strong); }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.form-row input::placeholder, .form-row textarea::placeholder { color: var(--text-muted); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

/* ============================================================
   Tables génériques
   ============================================================ */
table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--surface-2); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
}
.badge-admin    { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.badge-manager  { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.badge-viewer   { background: var(--surface-3); color: var(--text-soft); border-color: var(--border); }
.badge-active   { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.badge-inactive { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.badge-warning  { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }

/* ============================================================
   Toasts / alerts
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}
.toast {
  background: #fff;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 240ms cubic-bezier(.2,.7,.2,1);
  font-size: 13.5px;
  color: var(--text-strong);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 160ms ease-out;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 26px 28px;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  animation: modalUp 220ms cubic-bezier(.2,.7,.2,1);
}
@keyframes modalUp {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal h3 {
  margin: 0 0 18px 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

/* ============================================================
   Login
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 20% 0%, rgba(99,102,241,0.18), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(168,85,247,0.16), transparent 60%),
    linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  padding: 20px;
  position: relative;
}
.login-card {
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 64px -12px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
  animation: modalUp 320ms cubic-bezier(.2,.7,.2,1);
}
.login-card .logo {
  text-align: center;
  font-size: 36px;
  margin-bottom: 4px;
  display: flex;
  justify-content: center;
}
.login-card .logo > span {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.04em;
  box-shadow: 0 12px 28px -6px rgba(99,102,241,0.5), inset 0 1px 0 rgba(255,255,255,0.25);
}
.login-card h1 {
  text-align: center;
  margin: 18px 0 4px 0;
  font-size: 22px;
  color: var(--text-strong);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-card .subtitle {
  text-align: center;
  color: var(--text-soft);
  margin-bottom: 28px;
  font-size: 13.5px;
}
.login-card .error-msg {
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  margin-bottom: 14px;
  font-size: 13px;
  display: none;
}
.login-card .error-msg.show { display: block; animation: shake 380ms cubic-bezier(.2,.7,.2,1); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-4px); }
  40%,80% { transform: translateX(4px); }
}
.login-card button[type="submit"] {
  width: 100%;
  margin-top: 6px;
  padding: 11px;
  font-size: 14px;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.empty .icon { font-size: 36px; margin-bottom: 10px; opacity: 0.55; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}
.tab {
  padding: 10px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--t-fast);
  font-family: inherit;
}
.tab:hover { color: var(--text-strong); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============================================================
   Pages internes (top-ventes, comparaison, …)
   ============================================================ */
.page { padding: 32px 28px 48px; max-width: 1440px; margin: 0 auto; }
.page-header { margin-bottom: 24px; }
.page-header h1 {
  margin: 0 0 6px 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.muted { color: var(--text-soft); font-size: 13px; }

.filters {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.filters label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.filters select, .filters input {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.filters select:hover, .filters input:hover { border-color: var(--border-strong); }
.filters select:focus, .filters input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}
.loading::before {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
  margin-right: 8px;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  padding: 14px 18px;
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-xs);
  color: #991b1b;
  font-size: 13.5px;
}

/* ============================================================
   data-table (utilisée partout)
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table thead {
  background: var(--surface-2);
}
.data-table th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 1;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table th.num { text-align: right; }
.data-table code {
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-soft);
}

/* ============================================================
   Comparaison & statistiques
   ============================================================ */
.container { padding: 32px 28px 48px; max-width: 1440px; margin: 0 auto; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.summary-grid .kpi {
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.summary-grid .kpi .kpi-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.summary-grid .kpi .kpi-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text-strong);
  word-break: break-word;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.summary-grid .kpi .kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.evo-up   { color: var(--success); font-weight: 600; }
.evo-down { color: var(--danger);  font-weight: 600; }
.evo-flat { color: var(--text-muted); }
.mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12px; }
.data-table .mono { color: var(--text-soft); }

/* Bouton stats sur top-ventes */
.btn-stats {
  background: var(--warning-soft);
  color: #92400e;
  border-color: #fde68a;
  box-shadow: var(--shadow-xs);
}
.btn-stats:hover { background: #fde68a; border-color: #fcd34d; }

/* ============================================================
   Recherche + scanner
   ============================================================ */
.search-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.search-input-wrap input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-input-wrap input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.scan-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border: none;
  background: var(--brand-gradient);
  color: #fff;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: filter var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  box-shadow: 0 4px 10px -2px rgba(99,102,241,0.4);
  font-family: inherit;
}
.scan-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }

/* Overlay plein-écran scanner */
.scanner-overlay {
  position: fixed; inset: 0;
  background: #000;
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.scanner-video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.scanner-frame {
  position: absolute;
  width: min(80vw, 360px);
  height: min(40vw, 180px);
  border: 3px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  pointer-events: none;
}
.scanner-hint {
  position: absolute;
  bottom: 32px; left: 16px; right: 16px;
  text-align: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.85);
  pointer-events: none;
}
.scanner-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.scanner-close:hover { background: rgba(0,0,0,0.85); }

/* ============================================================
   Photos produits
   ============================================================ */
.product-photo {
  width: 56px; height: 56px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}
.photo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  font-size: 22px;
  color: var(--text-muted);
}
.data-table td.photo-cell { padding: 6px 8px; width: 70px; }

/* ============================================================
   Tooltip historique produit
   ============================================================ */
.history-tooltip {
  position: absolute;
  z-index: 9999;
  width: 380px;
  max-width: 92vw;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-xl);
  font-size: 13px;
  color: var(--text);
  max-height: 90vh;
  overflow-y: auto;
}
.history-tooltip .ph-layout { display: flex; flex-direction: column; gap: 12px; }
.history-tooltip .ph-main { min-width: 0; flex: 1; }
.history-tooltip .ph-others {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  min-width: 0;
}
.history-tooltip:has(.ph-others) { width: 720px; }
@media (min-width: 900px) {
  .history-tooltip:has(.ph-others) .ph-layout { flex-direction: row; align-items: flex-start; }
  .history-tooltip:has(.ph-others) .ph-others {
    flex: 0 0 280px;
    border-top: none;
    border-left: 1px dashed var(--border);
    padding-top: 0;
    padding-left: 12px;
  }
}
.history-tooltip .ph-others .ph-section-title { margin-top: 0; padding-top: 0; border-top: none; }

.history-tooltip .ph-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-strong);
  line-height: 1.3;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.history-tooltip .ph-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.history-tooltip .ph-legend-item { display: inline-flex; align-items: center; gap: 5px; }
.history-tooltip .ph-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.history-tooltip .ph-rows { display: flex; flex-direction: column; gap: 10px; }
.history-tooltip .ph-row { display: block; }
.history-tooltip .ph-period { font-size: 12px; font-weight: 500; color: var(--text-soft); margin-bottom: 4px; }
.history-tooltip .ph-bars { display: flex; flex-direction: column; gap: 3px; }
.history-tooltip .ph-bar-wrap {
  position: relative;
  height: 18px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.history-tooltip .ph-bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 5px;
  transition: width .25s ease;
}
.history-tooltip .ph-bar-qty { background: linear-gradient(90deg, #6366f1, #818cf8); }
.history-tooltip .ph-bar-rev { background: linear-gradient(90deg, #059669, #34d399); }
.history-tooltip .ph-bar-label {
  position: absolute;
  top: 50%; left: 6px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-strong);
  font-weight: 500;
  text-shadow: 0 0 3px rgba(255,255,255,.85);
}
.history-tooltip .ph-totals {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}
.history-tooltip .ph-loading,
.history-tooltip .ph-error {
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.history-tooltip .ph-error { color: var(--danger); }
.history-tooltip .ph-section-title {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-soft);
}
.history-tooltip .ph-mini { margin-top: 6px; }
.history-tooltip .ph-mini-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 2px;
}
.history-tooltip .ph-mini-tot { font-size: 10px; color: var(--text-muted); font-weight: 400; }
.history-tooltip .ph-mini-svg { display: block; width: 100%; height: 60px; }
.history-tooltip .ph-mini-label { font-size: 8px; fill: var(--text-muted); }
.history-tooltip .ph-mini-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 2px 0;
}

/* Style libellé déclencheur tooltip */
[data-product-history] {
  cursor: help;
  position: relative;
  text-decoration: underline dotted transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--t-fast);
}
[data-product-history]:hover { text-decoration-color: #94a3b8; }
@media (hover: none) and (pointer: coarse) {
  [data-product-history] strong {
    text-decoration: underline dotted #94a3b8 1px;
    text-underline-offset: 3px;
  }
}

/* ============================================================
   Barre de recherche client
   ============================================================ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.search-bar label { font-weight: 500; font-size: 13px; color: var(--text-soft); }
.search-bar input[type="search"] {
  flex: 1 1 320px;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.search-bar .small { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   Badges Type d'import
   ============================================================ */
.kind-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.kind-badge.kind-agg   { background: var(--surface-3); color: #374151; border-color: var(--border); }
.kind-badge.kind-sales { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.kind-badge.kind-rec   { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.kind-badge.kind-stock { background: var(--warning-soft); color: #92400e; border-color: #fde68a; }

/* ============================================================
   Top ventes — indicateurs
   ============================================================ */
td.stock-neg { color: var(--danger); font-weight: 600; }
td.stock-low { color: #c2410c; font-weight: 600; }
.cell-family { font-size: 12px; color: var(--text-soft); }

/* Pastilles présence multi-magasins */
td.pp-cell { white-space: nowrap; padding: 4px 6px; }
.pp-pill {
  display: inline-block;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 5px;
  margin: 1px 1px;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  letter-spacing: .3px;
  min-width: 28px;
  text-align: center;
  transition: transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.pp-pill:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pp-pill[disabled], .pp-pill:not([data-presence-pill]) { cursor: default; }
.pp-pill.pp-full  { background: var(--success); color: #fff; border-color: #047857; }
.pp-pill.pp-stock { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.pp-pill.pp-sold  { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.pp-pill.pp-none  { background: var(--surface-3); color: #9ca3af; border-color: var(--border); }
.pp-pill.pp-current { box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--primary); }

/* ============================================================
   Modale détail produit (.pd-*)
   ============================================================ */
.pd-overlay { z-index: 1000; transition: opacity var(--t-fast); }
.pd-modal {
  width: min(1500px, 95vw);
  max-width: min(1500px, 95vw);
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}
.pd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.pd-header .pd-titles { flex: 1; min-width: 0; }
.pd-header .pd-nav { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pd-prev, .pd-next {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  font-family: inherit;
}
.pd-prev:hover:not(:disabled), .pd-next:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}
.pd-prev:disabled, .pd-next:disabled { opacity: .4; cursor: not-allowed; }
.pd-pos { margin-left: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-soft); font-size: 12px; }

.pd-hero {
  display: flex;
  align-items: flex-start;
  gap: 22px;
  margin-bottom: 16px;
}
.pd-photo-wrap {
  flex: 0 0 auto;
  width: 180px; height: 180px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.pd-photo-wrap .product-photo { width: 100%; height: 100%; object-fit: contain; border: none; background: transparent; border-radius: 0; }
.pd-photo-wrap .photo-placeholder { width: 100%; height: 100%; font-size: 56px; border: none; background: transparent; border-radius: 0; }
.pd-hero-info { flex: 1; min-width: 0; }
@media (max-width: 720px) {
  .pd-hero { flex-direction: column; }
  .pd-photo-wrap { width: 140px; height: 140px; align-self: center; }
}
.pd-title { font-size: 17px; font-weight: 700; color: var(--text-strong); line-height: 1.3; letter-spacing: -0.01em; }
.pd-sub { font-size: 12.5px; margin-top: 4px; color: var(--text-soft); }
.pd-close {
  background: transparent;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 8px;
  transition: all var(--t-fast);
  font-family: inherit;
}
.pd-close:hover { color: var(--text-strong); background: var(--surface-3); }

.pd-body { padding: 18px 22px 22px; overflow-y: auto; flex: 1; }
.pd-body h4 {
  margin: 20px 0 10px;
  font-size: 13.5px;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pd-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.pd-kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.pd-kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.pd-kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.pd-kpi-value { font-size: 20px; font-weight: 700; color: var(--text-strong); margin-top: 2px; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; min-width: 0; }
.pd-kpi-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; min-width: 0; }
.pd-kpi { min-width: 0; }
.pd-kpi-label { overflow-wrap: anywhere; }
.pd-kpi-dates { font-size: 13px; }
.pd-kpi.pd-kpi-warn .pd-kpi-value { color: var(--danger); }
.pd-kpi.pd-kpi-warn { background: var(--danger-soft); border-color: #fecaca; }

/* === KPI Stock courant : ambre quand stock > 0, rouge quand stock <= 0 === */
/* Effet "halo" lumineux pulsé pour attirer l'œil immédiatement. */
.pd-kpi.pd-kpi-stock { position: relative; border-width: 2px; }

.pd-kpi.pd-kpi-stock-ok {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55), 0 1px 2px rgba(0,0,0,0.04);
  animation: pd-kpi-glow-amber 2.4s ease-in-out infinite;
}
.pd-kpi.pd-kpi-stock-ok .pd-kpi-value { color: #b45309; text-shadow: 0 0 8px rgba(245, 158, 11, 0.35); }
.pd-kpi.pd-kpi-stock-ok .pd-kpi-label { color: #92400e; }

.pd-kpi.pd-kpi-stock-ko {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border-color: #dc2626;
  box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.65), 0 1px 2px rgba(0,0,0,0.04);
  animation: pd-kpi-glow-red 1.6s ease-in-out infinite;
}
.pd-kpi.pd-kpi-stock-ko .pd-kpi-value { color: #b91c1c; text-shadow: 0 0 10px rgba(220, 38, 38, 0.45); }
.pd-kpi.pd-kpi-stock-ko .pd-kpi-label { color: #991b1b; }

@keyframes pd-kpi-glow-amber {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55), 0 1px 2px rgba(0,0,0,0.04); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.00), 0 0 18px rgba(245, 158, 11, 0.45); }
}
@keyframes pd-kpi-glow-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.65), 0 1px 2px rgba(0,0,0,0.04); }
  50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.00), 0 0 22px rgba(220, 38, 38, 0.55); }
}
@media (prefers-reduced-motion: reduce) {
  .pd-kpi.pd-kpi-stock-ok, .pd-kpi.pd-kpi-stock-ko { animation: none; }
}

.pd-product {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 6px 0 0;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12.5px;
}
.pd-product dt { color: var(--text-muted); font-weight: 500; }
.pd-product dd { margin: 0; color: var(--text-strong); font-weight: 600; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
/* Évite que les valeurs longues (Sous-famille "LEGO CLASSIC", Rayon "FIG ACTION/VEHICULES"…)
   débordent à droite des cards latérales : on autorise le wrap dans la 2ᵉ colonne. */

.pd-legend { display: flex; gap: 18px; margin: 4px 0 8px; font-size: 12px; color: var(--text-soft); }
.pd-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pd-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.pd-swatch.pd-bar-in  { background: var(--success); }
.pd-swatch.pd-bar-out { background: var(--primary); }

.pd-chart-wrap {
  overflow-x: auto;
  padding: 8px 0 12px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Panneau "Ventes par mois" / "Réceptions par mois" — séries par année */
.pd-year-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 8px;
  margin: 10px 0 14px;
  box-shadow: var(--shadow-sm);
}
.pd-year-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 4px;
}
.pd-year-totals { display: flex; flex-wrap: wrap; gap: 14px 18px; font-size: 12px; color: var(--text-soft); }
.pd-yt {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-soft, rgba(15,23,42,0.04));
  border: 1px solid var(--border);
}
.pd-yt strong { color: var(--text-strong); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.pd-yt-sub { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.pd-yt-sub .muted { font-weight: 400; }
.pd-yt-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 1px 2px rgba(0,0,0,0.18); }
.pd-year-hint { font-size: 11px; }
.pd-rupture-ctl {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin: 8px 0 4px; padding: 8px 12px;
  background: rgba(220, 38, 38, 0.05);
  border: 1px solid rgba(220, 38, 38, 0.18);
  border-left: 3px solid #dc2626;
  border-radius: var(--radius);
  font-size: 12px;
}
.pd-rupture-ctl label { font-weight: 600; color: var(--text-strong); }
.pd-rupture-year {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text-strong);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.pd-rupture-info { flex: 1; min-width: 200px; color: var(--text-soft); }
.pd-rupture-detail-btn {
  padding: 4px 10px; border: 1px solid #dc2626; border-radius: 6px;
  background: #fff; color: #dc2626;
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.pd-rupture-detail-btn:hover { background: #dc2626; color: #fff; }
.pd-rupture-panel {
  margin: 8px 0 12px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xs);
}
.pd-rupture-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 8px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.pd-rupture-panel-head strong { font-size: 13px; color: var(--text-strong); }
.pd-rupture-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-soft); }
.pd-rupture-legend span { display: inline-flex; align-items: center; gap: 5px; }
.pd-rupture-legend .lg-sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.pd-rupture-periods { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.pd-rupture-periods .rxp-title { font-size: 12px; font-weight: 700; color: var(--text-strong); margin-bottom: 6px; }
.pd-rupture-periods .rxp-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 12px; }
.pd-rupture-periods .rxp-list li { font-size: 12px; color: var(--text-strong); display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.pd-rupture-periods .rxp-dot { display: inline-block; width: 8px; height: 8px; background: #dc2626; border-radius: 50%; flex-shrink: 0; }
.pd-year-panel .pd-chart-wrap { background: transparent; border: none; padding: 0; overflow-x: hidden; width: 100%; }
.pd-year-panel .pd-chart-wrap > div { width: 100% !important; max-width: 100%; }
/* Tooltip premium partagé entre les charts ApexCharts (rx-tip) */
.rx-tip .rx-tip-inner { padding: 8px 12px; min-width: 180px; }
.rx-tip .ttl { font-weight: 700; font-size: 12.5px; margin-bottom: 6px; color: var(--text-strong); }
.rx-tip .row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 2px 0; font-size: 12px; }
.rx-tip .row .lbl { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.rx-tip .row .val { color: var(--text-strong); font-variant-numeric: tabular-nums; font-weight: 600; }
.rx-tip .row .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pd-chart { display: block; height: auto; }
.pd-chart .pd-grid { stroke: var(--border); stroke-width: 1; }
.pd-chart .pd-axis { font-size: 13px; fill: var(--text-soft); font-family: inherit; }
.pd-chart .pd-axis-x { font-size: 11px; }
.pd-chart .pd-bar-in  { fill: var(--success); }
.pd-chart .pd-bar-out { fill: var(--primary); }
.pd-chart .pd-bar { transition: opacity var(--t-fast); }
.pd-chart .pd-bar:hover { opacity: .8; }

.pd-mvts { font-size: 12px; }
.pd-mvts th, .pd-mvts td { padding: 6px 10px; }
.pd-sens {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pd-sens-in  { background: var(--success-soft); color: #065f46; }
.pd-sens-out { background: #dbeafe; color: #1e40af; }

/* Modale détail produit : sous-vue par sub_store */
.pd-substores-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 4px;
}
@media (max-width: 720px) { .pd-substores-grid { grid-template-columns: 1fr; } }
.pd-substore-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface-2);
  min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.pd-substore-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.pd-substore-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.pd-substore-label { font-weight: 700; font-size: 13px; color: var(--primary-dark); }
.pd-substore-stats { white-space: nowrap; }
.pd-substore-empty { padding: 18px 6px; text-align: center; color: var(--text-muted); }
.pd-chart-mini text.pd-axis-x { font-size: 9px; }

/* Comparaison "autres magasins" */
.pd-other-stores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 12px;
  margin-top: 8px;
}
.pd-other-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface-2);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.pd-other-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.pd-other-card.pd-other-empty { background: var(--surface-2); opacity: 0.7; }
.pd-other-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.pd-other-name { font-weight: 600; font-size: 13px; color: var(--text-strong); }
.pd-other-kpis { font-size: 11px; }
.pd-other-aggrows { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.pd-other-aggrow-label { margin-bottom: 2px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .main { padding: 24px 18px 36px; }
  .page { padding: 24px 18px 36px; }
  .container { padding: 24px 18px 36px; }
  .card { padding: 18px 20px; }
  .page-title, .page-header h1 { font-size: 22px; }
  .kpi .value, .kpi .kpi-value { font-size: 24px; }
  .topbar { padding: 10px 18px; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar .brand { font-size: 14px; gap: 8px; }
  .topbar .brand .logo { width: 30px; height: 30px; font-size: 14px; }
  .topbar .brand .brand-name small { display: none; }
  .topbar nav {
    order: 3; width: 100%; justify-content: flex-start;
    gap: 4px; overflow-x: auto; flex-wrap: nowrap;
    padding-bottom: 2px; margin-left: 0;
    -webkit-overflow-scrolling: touch;
  }
  .topbar nav::-webkit-scrollbar { height: 0; }
  .topbar nav a { padding: 7px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
  .topbar .user-info { gap: 8px; }
  .topbar .user-info .who { gap: 0; }
  .topbar .user-info .who .role { display: none; }
  .topbar .user-info .actions button { padding: 6px 10px; font-size: 11px; }

  .main { padding: 16px 12px 28px; }
  .page { padding: 16px 12px 28px; }
  .container { padding: 16px 12px 28px; }

  .page-title { font-size: 19px; }
  .page-subtitle { margin-bottom: 16px; font-size: 13px; }
  .page-header h1 { font-size: 19px; }

  .card { padding: 16px; border-radius: var(--radius); margin-bottom: 14px; }
  .card-header { margin-bottom: 14px; }
  .card-title { font-size: 14.5px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi { padding: 14px; }
  .kpi .label, .kpi .kpi-label { font-size: 10px; }
  .kpi .value, .kpi .kpi-value { font-size: 20px; }
  .kpi .hint { font-size: 11px; }
  .kpi .kpi-icon { width: 28px; height: 28px; font-size: 14px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .summary-grid .kpi { padding: 12px 14px; }
  .summary-grid .kpi .kpi-value { font-size: 17px; }

  .filters { display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 100%; }
  .filters label { font-size: 11px; }
  .filters select, .filters input { width: 100%; padding: 9px 10px; font-size: 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-row.two { grid-template-columns: 1fr; }

  .search-bar { display: flex; flex-direction: column; gap: 6px; }
  .search-input-wrap { gap: 6px; }
  .search-input-wrap input[type="search"] { padding: 10px 12px; font-size: 14px; }
  .scan-btn { padding: 10px 12px; font-size: 13px; min-height: 40px; }

  .btn { padding: 9px 14px; font-size: 13px; min-height: 38px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  .data-table th { padding: 9px 10px; font-size: 10px; }
  .data-table td { padding: 9px 10px; font-size: 12px; }
  .data-table code { font-size: 11px; padding: 1px 4px; }
  .data-table .photo-cell { width: 50px; padding: 4px 6px; }
  .data-table .product-photo,
  .data-table .photo-cell .photo-placeholder { width: 42px; height: 42px; }

  .login-card { width: calc(100% - 24px); padding: 28px 22px; }

  .pd-modal { width: 98vw; max-width: 98vw; max-height: 92vh; }
  .pd-overlay { padding: 4px; }
  .pd-header { padding: 12px 14px; gap: 8px; }
  .pd-title { font-size: 14px; }
  .pd-sub { font-size: 11px; }
  .pd-body { padding: 14px; }
}

@media (max-width: 600px) {
  .history-tooltip { width: 95vw; max-width: 95vw; padding: 12px; font-size: 12px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .topbar .user-info .who .name { display: none; }
  .pd-prev, .pd-next { width: 28px; height: 28px; font-size: 16px; }
  .pd-pos { font-size: 11px; }
}

/* ============================================================
   Utilities
   ============================================================ */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.text-soft    { color: var(--text-soft); }
.tabular      { font-variant-numeric: tabular-nums; }
.divider      { height: 1px; background: var(--border); margin: 16px 0; border: none; }

/* ============================================================
   Sidebar layout (desktop) + mobile drawer + dark mode
   ============================================================ */

/* Sidebar : visible >= 1024px, drawer < 1024px */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(-100%);
  transition: transform var(--t-base);
  box-shadow: var(--shadow-md);
}
.sidebar .sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--text-strong);
  flex-shrink: 0;
}
.sidebar .sb-brand .logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand-gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 800;
  box-shadow: 0 6px 16px -4px rgba(99,102,241,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  letter-spacing: -0.02em;
}
.sidebar .sb-brand .brand-name { display: flex; flex-direction: column; line-height: 1.1; font-size: 15px; }
.sidebar .sb-brand .brand-name small {
  font-size: 10.5px; color: var(--text-muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px;
}

.sidebar .sb-nav {
  flex: 1;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.sidebar .sb-nav .sb-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 14px 12px 6px;
}
.sidebar .sb-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--t-fast);
  position: relative;
}
.sidebar .sb-nav a .nav-ico {
  width: 18px; text-align: center; opacity: 0.85;
  font-size: 14px;
}
.sidebar .sb-nav a:hover {
  background: var(--surface-3);
  color: var(--text-strong);
  text-decoration: none;
}
.sidebar .sb-nav a.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}
.sidebar .sb-nav a.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-gradient);
}

.sidebar .sb-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar .sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.sidebar .sb-user .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 10px -2px rgba(99,102,241,0.4), inset 0 1px 0 rgba(255,255,255,0.25);
  flex-shrink: 0;
}
.sidebar .sb-user .who {
  display: flex; flex-direction: column; line-height: 1.25;
  min-width: 0;
}
.sidebar .sb-user .who .name {
  font-weight: 600;
  color: var(--text-strong);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .sb-user .who .role {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .sb-foot .sb-actions {
  display: flex; gap: 6px;
}
.sidebar .sb-foot .sb-actions button {
  flex: 1;
  background: var(--surface);
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all var(--t-fast);
  font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.sidebar .sb-foot .sb-actions button:hover {
  background: var(--surface-3);
  color: var(--text-strong);
  border-color: var(--border-strong);
}
.sidebar .sb-foot .sb-actions button.danger:hover {
  color: var(--danger);
  border-color: rgba(220,38,38,0.3);
  background: var(--danger-soft);
}
.sidebar .sb-theme-toggle {
  background: var(--surface);
  color: var(--text-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: space-between;
  gap: 8px;
  transition: all var(--t-fast);
}
.sidebar .sb-theme-toggle:hover {
  background: var(--surface-3);
  color: var(--text-strong);
  border-color: var(--border-strong);
}
.sidebar .sb-theme-toggle .sw {
  display: inline-block; width: 28px; height: 16px; border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background var(--t-fast);
}
.sidebar .sb-theme-toggle .sw::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff;
  transition: transform var(--t-fast);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
html.dark .sidebar .sb-theme-toggle .sw { background: var(--primary); }
html.dark .sidebar .sb-theme-toggle .sw::after { transform: translateX(12px); }

/* Mobile topbar (hamburger) — visible < 1024px uniquement */
.topbar-mobile {
  display: none;
  position: sticky; top: 0; z-index: 55;
  background: rgba(255,255,255,0.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(15,23,42,0.06);
  padding: 10px 16px;
  align-items: center;
  gap: 12px;
}
.topbar-mobile .ham {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  cursor: pointer;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  flex-shrink: 0;
}
.topbar-mobile .ham span {
  display: block; width: 16px; height: 2px;
  background: var(--text-strong);
  border-radius: 1px;
}
.topbar-mobile .brand-mini {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--text-strong);
}
.topbar-mobile .brand-mini .logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--brand-gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 800;
  box-shadow: 0 4px 10px -2px rgba(99,102,241,0.4);
}
.topbar-mobile .spacer { flex: 1; }

/* Backdrop derrière le drawer mobile */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 59;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}
body.sidebar-open .sidebar { transform: translateX(0); }

/* Layout : quand body a la sidebar, on pousse le contenu sur desktop */
@media (min-width: 1024px) {
  body.has-sidebar .sidebar { transform: translateX(0); }
  body.has-sidebar .topbar-mobile { display: none !important; }
  body.has-sidebar .sidebar-backdrop { display: none; }
  body.has-sidebar { padding-left: 248px; }
  body.has-sidebar .topbar { display: none; }
  body.has-sidebar .main { padding-top: 32px; }
}
@media (max-width: 1023.98px) {
  body.has-sidebar .topbar-mobile { display: flex; }
  body.has-sidebar .topbar { display: none; }
}

/* ============================================================
   Dark mode
   ============================================================ */
html.dark {
  color-scheme: dark;
  --bg-page:    #0b1220;
  --bg-card:    #131a2b;
  --surface:    #131a2b;
  --surface-2:  #182238;
  --surface-3:  #1f2a44;
  --bg:         #050816;
  --bg-soft:    #0b1220;

  --text:        #e7eaf3;
  --text-strong: #f4f6fb;
  --text-soft:   #b8bfd1;
  --text-muted:  #7d869c;

  --border:        #243049;
  --border-strong: #34425f;
  --ring:          rgba(139, 92, 246, 0.35);

  --primary:       #818cf8;
  --primary-dark:  #a5b1ff;
  --primary-soft:  #1e2746;
  --accent:        #a78bfa;

  --success-soft: #062a1c;
  --danger-soft:  #2a0d0d;
  --warning-soft: #2a1a05;
  --info-soft:    #06222d;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.40), 0 1px 1px rgba(0,0,0,0.25);
  --shadow:    0 2px 4px rgba(0,0,0,0.30), 0 4px 12px rgba(0,0,0,0.40);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.35), 0 10px 24px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 24px -8px rgba(0,0,0,0.5), 0 24px 48px -12px rgba(0,0,0,0.55);
  --shadow-xl: 0 24px 48px -12px rgba(0,0,0,0.6), 0 48px 96px -24px rgba(0,0,0,0.65);
}
html.dark body { background: var(--bg-page); color: var(--text); }
html.dark body::before {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(99,102,241,0.10), transparent 60%),
    radial-gradient(900px 500px at 110% 0%,  rgba(168,85,247,0.08), transparent 60%);
}
html.dark .topbar,
html.dark .topbar-mobile {
  background: rgba(19,26,43,0.75);
  border-bottom-color: rgba(255,255,255,0.06);
}
html.dark * { scrollbar-color: #34425f transparent; }
html.dark *::-webkit-scrollbar-thumb { background: #34425f; background-clip: padding-box; }
html.dark *::-webkit-scrollbar-thumb:hover { background: #475571; background-clip: padding-box; }

/* Dark mode : login en plus dramatique */
html.dark body.login-page { background: linear-gradient(135deg, #050816 0%, #0e0a1f 50%, #1a0a2e 100%); }
html.dark .login-card { background: rgba(19,26,43,0.92); }

/* Dark mode : tweak quelques specifics */
html.dark .kpi-icon.blue   { background: rgba(96,165,250,0.18); color: #93c5fd; }
html.dark .kpi-icon.green  { background: rgba(52,211,153,0.18); color: #6ee7b7; }
html.dark .kpi-icon.amber  { background: rgba(251,191,36,0.18); color: #fcd34d; }
html.dark .kpi-icon.red    { background: rgba(248,113,113,0.18); color: #fca5a5; }
html.dark .badge-active    { background: rgba(52,211,153,0.18); color: #6ee7b7; }
html.dark .badge-inactive  { background: rgba(148,163,184,0.18); color: #cbd5e1; }
html.dark .btn-primary     { box-shadow: 0 6px 16px -4px rgba(129,140,248,0.5), inset 0 1px 0 rgba(255,255,255,0.15); }

/* === Filtre de dates de l'histogramme (modale produit) === */
.pd-hist-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 0 10px 0;
  background: linear-gradient(180deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: 8px;
  font-size: 13px;
}
.pd-hist-filter-lbl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #78350f;
}
.pd-hist-filter-input {
  padding: 4px 8px;
  border: 1px solid #d97706;
  border-radius: 5px;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
}
.pd-hist-filter-input:focus {
  outline: none;
  border-color: #b45309;
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15);
}
.pd-hist-filter-clear {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #d97706;
  border-radius: 5px;
  color: #92400e;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.pd-hist-filter-clear:hover { background: #fde68a; }

/* === Layout 2 colonnes : hero (photo + infos) à gauche, histogramme à droite === */
.pd-top-row {
  display: block;
}
.pd-top-row.has-hist {
  display: grid;
  /* Colonne gauche (photo + cards KPI/produit) : largeur élastique entre
     320px et 520px, qui grossit selon le contenu (libellés longs comme
     "FIG ACTION/VEHICULES"). La colonne droite (graphique) absorbe le reste. */
  grid-template-columns: minmax(320px, fit-content(520px)) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.pd-top-row .pd-hero {
  margin-bottom: 0;
}
.pd-hist-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pd-hist-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 700;
}
.pd-hist-col .pd-hist-slot {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
@media (max-width: 1100px) {
  .pd-top-row.has-hist {
    grid-template-columns: 1fr;
  }
}

/* === Bouton "Commander chez le fournisseur" (B2B) ===================== */
.pd-b2b-wrap {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
}
.pd-b2b-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #facc15 0%, #f59e0b 100%);
  color: #1e1b07;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid #b45309;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  white-space: nowrap;
}
.pd-b2b-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.35);
  filter: brightness(1.05);
}
.pd-b2b-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(180, 83, 9, 0.25);
}
.pd-b2b-ref {
  background: rgba(0, 0, 0, 0.12);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Variante "deep-link" du bouton B2B : on indique visuellement que le clic
   ouvre directement la fiche produit (et non la page catalogue générique). */
.pd-b2b-btn-deep {
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  border-color: #047857;
  color: #fff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
}
.pd-b2b-btn-deep:hover {
  box-shadow: 0 4px 10px rgba(5, 150, 105, 0.45);
}
.pd-b2b-deep {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
  vertical-align: middle;
  margin: 0 2px;
}

/* === État "Commandé" : bandeau dans la modale + variante rouge =========
   Quand le gérant marque un produit comme commandé, la modale prend la
   classe `pd-ordered` qui repeint le fond en rouge clair et la bordure
   en rouge. Le bandeau `.pd-order-banner` affiche la date et un bouton
   d'annulation. La marque s'efface auto si une réception postérieure
   est importée (cf. centrale/imports.js productDetail). */
.pd-order-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 10px 0 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  flex-wrap: wrap;
}
.pd-order-banner.is-ordered {
  background: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
}
.pd-order-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.pd-order-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}
.btn-order-mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  color: #fff;
  border: 1px solid #b91c1c;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}
.btn-order-mark:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.35);
}
.btn-order-mark .pd-order-dot {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* Modale entière en mode "commandé" : fond rouge très clair + bordure rouge.
   On vise `.pd-modal` enfant direct de l'overlay marqué. */
.pd-overlay.pd-ordered .pd-modal {
  background: #fff5f5;
  border: 2px solid #ef4444;
  box-shadow: 0 20px 60px rgba(239, 68, 68, 0.25);
}
.pd-overlay.pd-ordered .pd-header {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  border-bottom: 1px solid #fca5a5;
}
