/* =====================================================
   SPICY IMMO — Design System
   Dark Mode • Glassmorphism • Premium
   ===================================================== */

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

/* ─── Variables ─────────────────────────────────────── */
:root {
  --bg:           #0f172a;
  --bg-alt:       #0a0f1e;
  --surface:      #1e293b;
  --surface-2:    #263348;
  --border:       #334155;
  --border-light: #1e3a5f;

  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #818cf8;
  --accent-glow:  rgba(99,102,241,0.25);

  --purple:       #8b5cf6;
  --teal:         #14b8a6;
  --amber:        #f59e0b;
  --red:          #ef4444;
  --green:        #10b981;
  --blue:         #3b82f6;

  --text:         #f1f5f9;
  --text-2:       #cbd5e1;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;

  --sidebar-w:    260px;
  --header-h:     64px;
  --radius:       14px;
  --radius-sm:    8px;
  --radius-lg:    20px;
  --shadow:       0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg:    0 12px 48px rgba(0,0,0,0.45);
  --transition:   0.2s ease;
}

/* ─── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
img { max-width: 100%; }
ul { list-style: none; }

/* ─── Layout ─────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 6px 18px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar-logo .brand {
  line-height: 1;
}

.sidebar-logo .brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar-logo .brand span {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  user-select: none;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(99,102,241,0.08);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,0.2), rgba(99,102,241,0.05));
  color: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
}

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--surface-2); }

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ─── Main ─────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ─── Header ─────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* ─── Global search (header) ──────────────────────────── */
.global-search {
  position: relative;
  flex: 1;
  max-width: 520px;
  margin: 0 0 0 24px;
}

.btn-magic-search {
  flex-shrink: 0;
  margin-left: 8px;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-magic-search:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99,102,241,0.45);
}
.btn-magic-search:active { transform: translateY(0); }
.global-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.global-search input {
  width: 100%;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 12px 9px 36px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: all .15s;
}
.global-search input::placeholder { color: var(--text-muted); }
.global-search input:focus {
  border-color: var(--accent);
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.55);
  max-height: 540px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}
.global-search-dropdown.open { display: block; }
.gs-section { padding: 6px 0; }
.gs-section + .gs-section { border-top: 1px solid var(--border); }
.gs-section-title {
  padding: 8px 14px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.gs-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
  color: inherit;
}
.gs-item:hover, .gs-item.active { background: rgba(99,102,241,0.1); }
.gs-item-icon { font-size: 1.1rem; flex-shrink: 0; }
.gs-item-main { flex: 1; min-width: 0; }
.gs-item-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-item-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.gs-item-meta {
  font-size: 0.78rem;
  color: var(--text-2);
  flex-shrink: 0;
  font-weight: 600;
}
.gs-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ─── Content ─────────────────────────────────────────── */
.content {
  padding: 28px;
  flex: 1;
}

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  border: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
}

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.3);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.25);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
}

.btn-icon:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

/* ─── Cards ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── KPI Cards ─────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 0 0 0 80px;
  opacity: 0.15;
}

.kpi-card.accent::before { background: var(--accent); }
.kpi-card.green::before  { background: var(--green); }
.kpi-card.amber::before  { background: var(--amber); }
.kpi-card.red::before    { background: var(--red); }
.kpi-card.teal::before   { background: var(--teal); }

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ─── Table ─────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead tr {
  background: rgba(30,41,59,0.8);
}

thead th {
  padding: 13px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid rgba(51,65,85,0.5);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover {
  background: rgba(99,102,241,0.05);
}

tbody td {
  padding: 12px 16px;
  color: var(--text-2);
  vertical-align: middle;
}

.td-primary {
  font-weight: 600;
  color: var(--text) !important;
}

/* ─── Badges / Statuts ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-brouillon  { background: rgba(100,116,139,0.2); color: #94a3b8; }
.badge-en_attente { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-commande   { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-livre      { background: rgba(20,184,166,0.15); color: #2dd4bf; }
.badge-facture    { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-paye       { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-planifie   { background: rgba(100,116,139,0.2); color: #94a3b8; }
.badge-en_cours   { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-termine    { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-suspendu   { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-admin      { background: rgba(139,92,246,0.2); color: #c4b5fd; }
.badge-gestionnaire { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-lecteur    { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* ─── Forms ─────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

select.form-control option {
  background: var(--surface);
  color: var(--text);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ─── Search bar ──────────────────────────────────────── */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-bar input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px 9px 36px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

/* Stock search bar en évidence */
.stock-search-highlight input {
  background: rgba(99,102,241,0.08);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12), 0 2px 8px rgba(99,102,241,0.15);
  font-size: 0.9rem;
}
.stock-search-highlight input:focus {
  box-shadow: 0 0 0 4px rgba(99,102,241,0.2), 0 4px 14px rgba(99,102,241,0.25);
}

/* Bouton magique stock (dans la page stock, plus visible) */
.btn-magic-stock {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 4px 14px rgba(99,102,241,0.35);
  white-space: nowrap;
  animation: pulse-glow 2.5s ease-in-out infinite;
}
.btn-magic-stock:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99,102,241,0.5);
}
.btn-magic-stock:active { transform: translateY(0); }
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
  50% { box-shadow: 0 4px 20px rgba(139,92,246,0.55); }
}

/* ─── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  padding: 16px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(12px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background var(--transition);
}

.btn-close:hover { background: var(--surface-2); color: var(--text); }

/* ─── Progress bar ───────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.progress-fill.ok     { background: linear-gradient(90deg, var(--green), #34d399); }
.progress-fill.warn   { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.progress-fill.danger { background: linear-gradient(90deg, var(--red), #f87171); }

/* ─── Charts ─────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card canvas {
  max-height: 220px;
}

/* ─── Toast ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  pointer-events: all;
  animation: toastIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--green); }
.toast.error   { border-left: 4px solid var(--red); }
.toast.info    { border-left: 4px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Upload zone ────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(15, 23, 42, 0.3);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}

.upload-zone .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.upload-zone strong {
  color: var(--accent-light);
}

/* ─── Stars rating ───────────────────────────────────── */
.stars {
  display: inline-flex;
  gap: 2px;
}

.star {
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-dim);
  transition: color var(--transition);
}

.star.filled, .star:hover, .star.hover { color: var(--amber); }

/* ─── Alert banners ──────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.alert-warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: #fbbf24;
}

.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  color: #34d399;
}

/* ─── Empty state ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 20px;
}

/* ─── Lignes commande ────────────────────────────────── */
.lignes-table {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ligne-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.6fr 0.8fr 0.8fr auto;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(51,65,85,0.5);
  align-items: center;
}

.ligne-row:last-child { border-bottom: none; }
.ligne-row.header {
  background: rgba(30,41,59,0.8);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ligne-total {
  text-align: right;
  padding: 10px;
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  background: rgba(30,41,59,0.5);
}

/* ─── Loader ─────────────────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(99,102,241,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ──────────────────────────────────────── */

/* Bouton hamburger (mobile) */
.btn-sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 1.4rem;
  line-height: 1;
  transition: background var(--transition);
}
.btn-sidebar-toggle:hover { background: var(--surface-2); }

/* Overlay sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  .btn-sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .ligne-row { grid-template-columns: 1fr 1fr auto; }
  /* Header : réduire la recherche globale */
  .global-search { max-width: 180px; margin-left: 8px; }
  .global-search input { font-size: 0.8rem; }
  /* Masquer le bouton magique header sur très petit écran */
  .header-actions .btn { font-size: 0.78rem; padding: 7px 12px; }
  /* KPI grid 1 col en dessous de 480px */
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .header { padding: 0 12px; gap: 8px; }
  .page-title { font-size: 0.95rem; }
  .global-search { max-width: 140px; }
  #btnMagicSearch { display: none; }
  .content { padding: 12px; }
  /* Stock : empiler la recherche */
  .stock-search-highlight { max-width: 100% !important; }
  .btn-magic-stock { font-size: 0.75rem; padding: 7px 10px; }
}

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

/* ─── Utilities ──────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.hidden { display: none !important; }
