/* ═══════════════════════════════════════════════════════════════════════════
   Atlas Sol — Portail Commercial
   Design System : noir & blanc + terracotta #C45A3C
   Typographie : Inter
═══════════════════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────────────────── */
:root {
  --white:           #FFFFFF;
  --warm-gray:       #F5F3F0;
  --warm-border:     #E8E4E0;
  --bg-subtle:       #FAFAF9;
  --text-primary:    #1A1A1A;
  --text-secondary:  #4A4A4A;
  --text-tertiary:   #8A8A8A;
  --terracotta:      #C45A3C;
  --terracotta-dk:   #A84830;
  --terracotta-bg:   #FDF1EE;
  --terracotta-line: #F0C7BC;
  --black:           #111111;
  --success:         #2E7D5B;
  --success-bg:      #EDF7F3;
  --error:           #C0392B;
  --error-bg:        #FDECEA;
  --warning:         #B7791F;
  --warning-bg:      #FEF3CD;
  --info:            #2C6E9E;
  --info-bg:         #EAF3FB;

  --bg-card:         #FFFFFF;
  --bg-main:         #F5F3F0;

  --sidebar-w:       240px;
  --topbar-h:        56px;

  --radius-sm:       4px;
  --radius-md:       8px;
  --radius-lg:       12px;
  --radius-xl:       16px;
  --radius-full:     999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.05);

  --transition: 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 15px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--warm-gray);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--warm-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--black);
  color: #E0E0E0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--warm-border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img {
  height: 52px;
  width: auto;
  border-radius: 0;
  padding: 0;
  border: none;
  background: none;
}
.sidebar-logo-text {
  align-items: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: #888;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.sidebar-close:hover { color: var(--white); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #1E1E1E;
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--terracotta);
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-rate {
  font-size: 0.6875rem;
  color: #777;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #A0A0A0;
  border-radius: 0;
  transition: color var(--transition), background var(--transition);
  position: relative;
}
.sidebar-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.04);
}
.sidebar-link.active {
  color: var(--white);
  background: rgba(196,90,60,0.15);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--terracotta);
  border-radius: 0 2px 2px 0;
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #1E1E1E;
  flex-shrink: 0;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #666;
  padding: 8px 0;
  transition: color var(--transition);
}
.sidebar-logout:hover { color: #ff6b5b; }

/* ─── Overlay mobile ─────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
  opacity: 0;
  transition: opacity var(--transition);
}
.sidebar-overlay.visible { opacity: 1; }
body.no-scroll { overflow: hidden; }

/* ─── Main wrapper ───────────────────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Topbar mobile ──────────────────────────────────────────────────────── */
.topbar-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--white);
  border-bottom: 1px solid var(--warm-border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 6px;
  border-radius: var(--radius-sm);
}
.topbar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}
.topbar-user-badge {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--terracotta);
  color: var(--white);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 32px 36px;
  max-width: 1280px;
  width: 100%;
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.page-header-left {}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─── Boutons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  line-height: 1;
}
.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--terracotta);
  color: var(--white);
  border-color: var(--terracotta);
}
.btn-primary:hover { background: var(--terracotta-dk); border-color: var(--terracotta-dk); }

.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border-color: var(--warm-border);
}
.btn-secondary:hover { border-color: #ccc; background: var(--bg-subtle); }

.btn-dark {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.btn-dark:hover { background: #222; border-color: #222; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: 9px 12px;
}
.btn-ghost:hover { background: var(--warm-gray); color: var(--text-primary); }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}
.btn-lg {
  padding: 12px 24px;
  font-size: 0.9375rem;
}
.btn-danger {
  background: var(--error);
  color: var(--white);
  border-color: var(--error);
}
.btn-danger:hover { background: #a93226; }

.btn-success {
  background: var(--success);
  color: var(--white);
  border-color: var(--success);
}
.btn-success:hover { background: #246147; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--warm-border);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--warm-border);
  gap: 12px;
}
.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--warm-border);
  background: var(--bg-subtle);
}

/* ─── KPI Cards ──────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kpi-value {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1;
}
.kpi-value.terracotta { color: var(--terracotta); }
.kpi-trend {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.kpi-icon.tc { background: var(--terracotta-bg); color: var(--terracotta); }
.kpi-icon.dark { background: #F0F0F0; color: var(--text-primary); }
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.blue { background: var(--info-bg); color: var(--info); }

/* ─── Gamification ───────────────────────────────────────────────────────── */
.gamif-section {
  background: var(--white);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  margin-bottom: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 40px;
  align-items: center;
}

.gauge-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}
.gauge-svg {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}
.gauge-track {
  fill: none;
  stroke: var(--warm-border);
  stroke-width: 10;
}
.gauge-fill {
  fill: none;
  stroke: var(--terracotta);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.gauge-amount {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
}
.gauge-label {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.gamif-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.gamif-level {
  display: flex;
  align-items: center;
  gap: 12px;
}
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.level-badge.bronze  { background: #FDF1EE; color: #A84830; border: 1.5px solid #F0C7BC; }
.level-badge.silver  { background: #F5F5F5; color: #5A5A5A; border: 1.5px solid #D0D0D0; }
.level-badge.gold    { background: #FDF8EC; color: #92671C; border: 1.5px solid #E8D38A; }
.level-badge.platinum{ background: #EFF3FA; color: #3D5A8A; border: 1.5px solid #BCC9E0; }

.gamif-progress-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gamif-progress-bar {
  height: 8px;
  background: var(--warm-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.gamif-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--terracotta), #E87050);
  transition: width 1s ease;
}
.gamif-streak {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}
.streak-count {
  font-weight: 700;
  color: var(--terracotta);
}
.gamif-next {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}
.gamif-next strong { color: var(--text-primary); }

/* ─── Sections ───────────────────────────────────────────────────────────── */
.section-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--warm-border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8375rem;
}
thead {
  background: var(--bg-subtle);
}
thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--warm-border);
}
tbody tr {
  border-bottom: 1px solid var(--warm-border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }
tbody td {
  padding: 13px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody td strong { color: var(--text-primary); font-weight: 600; }
tfoot td {
  padding: 12px 16px;
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-primary);
  border-top: 2px solid var(--warm-border);
}

/* ─── Badges & Status ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-draft     { background: #F0F0F0; color: #666; }
.badge-draft .badge-dot { background: #999; }
.badge-pending   { background: var(--warning-bg); color: var(--warning); }
.badge-pending .badge-dot { background: var(--warning); }
.badge-confirmed { background: var(--info-bg); color: var(--info); }
.badge-confirmed .badge-dot { background: var(--info); }
.badge-paid      { background: var(--success-bg); color: var(--success); }
.badge-paid .badge-dot { background: var(--success); }
.badge-cancelled { background: var(--error-bg); color: var(--error); }
.badge-cancelled .badge-dot { background: var(--error); }
.badge-shipped   { background: #F3F0FB; color: #6B4FA3; }
.badge-shipped .badge-dot { background: #6B4FA3; }
.badge-delivered { background: #EAF5EF; color: #2A6044; }
.badge-delivered .badge-dot { background: #2A6044; }
.badge-validated { background: var(--success-bg); color: var(--success); }
.badge-validated .badge-dot { background: var(--success); }
.badge-demande   { background: var(--info-bg); color: var(--info); }
.badge-demande .badge-dot { background: var(--info); }

/* Secteurs */
.sector-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--terracotta-bg);
  color: var(--terracotta);
  border: 1px solid var(--terracotta-line);
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
}
.sector-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ─── Formulaires ────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 20px;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}
label .required { color: var(--terracotta); margin-left: 2px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%;
  padding: 9px 13px;
  font-size: 0.875rem;
  border: 1.5px solid var(--warm-border);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(196,90,60,0.1);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238A8A8A' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-hint {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}
.form-error {
  font-size: 0.75rem;
  color: var(--error);
}
.input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.input-group input {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  border-right: none;
  flex: 1;
}
.input-addon {
  display: flex;
  align-items: center;
  padding: 9px 13px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--warm-border);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Checkbox */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--terracotta);
  cursor: pointer;
}

/* ─── Search bar ─────────────────────────────────────────────────────────── */
.search-bar {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-bar svg {
  position: absolute;
  left: 11px;
  color: var(--text-tertiary);
  pointer-events: none;
}
.search-bar input {
  padding-left: 36px;
  min-width: 240px;
}

/* ─── Filters ────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  background: var(--warm-gray);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--text-tertiary);
}
.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: 20px;
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #BDE5D5; }
.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #F4C0BC; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #F0D28A; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #AACDE8; }

/* ─── Modales ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--warm-border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--warm-border);
}

/* ─── Produit card ───────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--white);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.product-card-image {
  aspect-ratio: 16/10;
  background: var(--warm-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.product-card-image img { width: 100%; height: 100%; object-fit: cover; }
.product-card-image .no-img {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}
.product-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.product-card-cat {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--terracotta);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.product-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.product-card-ref {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}
.product-card-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: auto;
  padding-top: 8px;
}
.product-card-price span {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-tertiary);
}
.product-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--warm-border);
  background: var(--bg-subtle);
}

/* ─── Bon de commande ────────────────────────────────────────────────────── */
.order-line {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--warm-border);
}
.order-line:last-child { border-bottom: none; }
.order-line-name { font-size: 0.875rem; font-weight: 600; }
.order-line-ref  { font-size: 0.75rem; color: var(--text-tertiary); }
.order-summary {
  background: var(--bg-subtle);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.order-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.order-summary-row.total {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  border-top: 2px solid var(--warm-border);
  margin-top: 8px;
  padding-top: 12px;
}

/* ─── Print PDF ──────────────────────────────────────────────────────────── */
.print-only { display: none; }
@media print {
  .sidebar, .main-wrapper > .topbar-mobile, .page-actions,
  .btn, .filters-bar, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0; }
  .main-content { padding: 0; }
  .print-only { display: block; }
  .card { border: none; box-shadow: none; }
  body { background: white; font-size: 11pt; }
  .print-doc {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
  }
  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid #111;
  }
  .print-company h1 { font-size: 18pt; font-weight: 800; letter-spacing: -0.02em; }
  .print-company p  { font-size: 9pt; color: #555; margin-top: 4px; }
  .print-ref { text-align: right; }
  .print-ref h2 { font-size: 14pt; font-weight: 700; }
  .print-ref p  { font-size: 9pt; color: #555; }
  table { width: 100%; border-collapse: collapse; margin-top: 20px; }
  th { background: #111; color: white; padding: 8px 10px; font-size: 9pt; text-align: left; }
  td { padding: 8px 10px; font-size: 10pt; border-bottom: 1px solid #eee; }
  .print-totals { margin-top: 20px; text-align: right; }
  .print-totals tr td:first-child { color: #555; font-size: 9pt; padding-right: 24px; }
  .print-total-row { font-size: 13pt; font-weight: 800; }
}

/* ─── Commissions ────────────────────────────────────────────────────────── */
.commission-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.commission-total-card {
  background: var(--white);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.commission-total-card.highlighted {
  border-color: var(--terracotta-line);
  background: var(--terracotta-bg);
}
.commission-total-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.commission-total-amount {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}
.commission-total-amount.tc { color: var(--terracotta); }

/* ─── Profil ─────────────────────────────────────────────────────────────── */
.profil-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  background-image: radial-gradient(ellipse at 30% 50%, rgba(196,90,60,0.06) 0%, transparent 60%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.06);
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  gap: 12px;
}
.login-logo img {
  height: 72px;
  width: auto;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  border: 1px solid var(--warm-border);
}
.login-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.login-brand-name {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  text-align: center;
}
.login-brand-tag {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: center;
}
.login-title {
  font-size: 1.125rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.login-subtitle {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  text-align: center;
  margin-bottom: 28px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }

/* ─── Admin panel ────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--warm-border);
  margin-bottom: 24px;
}
.admin-tab {
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.admin-tab.active {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
}

/* ─── Leads / Kanban ─────────────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(200px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 28px;
}
.kanban-col {
  background: var(--warm-gray);
  border-radius: var(--radius-lg);
  border: 1px solid var(--warm-border);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--warm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kanban-col-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
.kanban-col-count {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--warm-border);
  color: var(--text-tertiary);
}
.kanban-cards {
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card {
  background: var(--white);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}
.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kanban-card-company {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kanban-card-contact {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kanban-card-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
}
.kanban-card-date {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}
.kanban-card-date.overdue {
  color: var(--error);
  font-weight: 600;
}

/* Kanban drag & drop */
.kanban-cards.drag-over {
  background: var(--terracotta-bg);
  border: 2px dashed var(--terracotta-line);
  border-radius: var(--radius-md);
}
.kanban-card[draggable] { cursor: grab; }
.kanban-card[draggable]:active { cursor: grabbing; }

/* Status colors */
.lead-status-nouveau     { border-left-color: #A0AEC0; }
.lead-status-contacte    { border-left-color: #4299E1; }
.lead-status-qualifie    { border-left-color: #9F7AEA; }
.lead-status-proposition { border-left-color: var(--warning); }
.lead-status-negociation { border-left-color: #ED8936; }
.lead-status-gagne       { border-left-color: var(--success); }
.lead-status-perdu       { border-left-color: var(--error); }

/* Kanban column accent */
.kanban-col[data-status="nouveau"]     .kanban-col-header { border-top: 3px solid #A0AEC0; }
.kanban-col[data-status="contacte"]    .kanban-col-header { border-top: 3px solid #4299E1; }
.kanban-col[data-status="qualifie"]    .kanban-col-header { border-top: 3px solid #9F7AEA; }
.kanban-col[data-status="proposition"] .kanban-col-header { border-top: 3px solid var(--warning); }
.kanban-col[data-status="negociation"] .kanban-col-header { border-top: 3px solid #ED8936; }
.kanban-col[data-status="gagne"]       .kanban-col-header { border-top: 3px solid var(--success); }
.kanban-col[data-status="perdu"]       .kanban-col-header { border-top: 3px solid var(--error); }

/* Priority dots */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.priority-dot.basse    { background: #A0AEC0; }
.priority-dot.normale  { background: #4299E1; }
.priority-dot.haute    { background: var(--warning); }
.priority-dot.urgente  { background: var(--error); }

/* Lead status badges */
.badge-lead-nouveau     { background: #EFF2F7; color: #5A6A82; }
.badge-lead-contacte    { background: #EBF8FF; color: #2B6CB0; }
.badge-lead-qualifie    { background: #FAF5FF; color: #6B46C1; }
.badge-lead-proposition { background: var(--warning-bg); color: var(--warning); }
.badge-lead-negociation { background: #FFFAF0; color: #C05621; }
.badge-lead-gagne       { background: var(--success-bg); color: var(--success); }
.badge-lead-perdu       { background: var(--error-bg); color: var(--error); }

/* Address autocomplete */
.autocomplete-wrap { position: relative; }
.autocomplete-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--warm-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 9px 13px;
  font-size: 0.8125rem;
  cursor: pointer;
  border-bottom: 1px solid var(--warm-border);
  transition: background var(--transition);
  color: var(--text-primary);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--warm-gray); }
.autocomplete-item-sub {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* Lead form API buttons */
.api-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1.5px solid var(--warm-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.api-btn:hover {
  border-color: var(--terracotta);
  color: var(--terracotta);
  background: var(--terracotta-bg);
}
.api-btn svg { flex-shrink: 0; }

/* Lead detail timeline */
.lead-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.lead-timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--warm-border);
  position: relative;
}
.lead-timeline-item:last-child { border-bottom: none; }
.lead-timeline-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--terracotta-bg);
  border: 2px solid var(--terracotta-line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.lead-timeline-content { flex: 1; }
.lead-timeline-date {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}
.lead-timeline-text {
  font-size: 0.8375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Pipeline widget */
.pipeline-widget {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pipeline-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
}
.pipeline-bar-label {
  width: 100px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  flex-shrink: 0;
}
.pipeline-bar-track {
  flex: 1;
  height: 8px;
  background: var(--warm-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.pipeline-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--terracotta);
  transition: width 0.8s ease;
}
.pipeline-bar-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  min-width: 20px;
  text-align: right;
}

/* Next actions widget */
.next-action-list { display: flex; flex-direction: column; gap: 8px; }
.next-action-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--warm-border);
  transition: box-shadow var(--transition);
}
.next-action-item:hover { box-shadow: var(--shadow-sm); }
.next-action-item.today { border-left: 3px solid var(--terracotta); }
.next-action-item.overdue { border-left: 3px solid var(--error); background: var(--error-bg); }
.next-action-item.tomorrow { border-left: 3px solid var(--warning); }
.next-action-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--terracotta-bg);
  color: var(--terracotta);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.next-action-body { flex: 1; min-width: 0; }
.next-action-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-action-desc {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-action-date {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.next-action-date.today-date { color: var(--terracotta); }
.next-action-date.overdue-date { color: var(--error); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .section-grid { grid-template-columns: 1fr; }
  .gamif-section { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .gamif-progress-label { justify-content: space-between; }
  .commission-header { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: flex; }
  .sidebar-overlay { display: block; }

  .main-wrapper { margin-left: 0; }
  .topbar-mobile { display: flex; }
  .main-content { padding: 20px 16px; }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .profil-grid { grid-template-columns: 1fr; }
  .commission-header { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { margin-bottom: 20px; }
  .product-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
  .table-wrap { font-size: 0.8rem; }
  thead th, tbody td { padding: 10px 12px; }
}
