:root {
  --gs-primary: #2563eb;
  --gs-primary-dark: #1d4ed8;
  --gs-accent: #0ea5e9;
  --gs-success: #16a34a;
  --gs-warning: #f59e0b;
  --gs-danger: #dc2626;
  --gs-sidebar-bg: #111827;
  --gs-sidebar-fg: #cbd5e1;
  --gs-sidebar-active: #1f2937;
  --gs-bg: #f1f5f9;
  --gs-card-border: #e2e8f0;
  --gs-text: #1e293b;
  --gs-text-muted: #64748b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--gs-bg);
  color: var(--gs-text);
  font-size: 0.925rem;
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #0ea5e9 100%);
  padding: 1rem;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card { border-radius: 1rem; }
.brand-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--gs-primary), var(--gs-accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.25rem;
  border-radius: 0.9rem;
}

/* ---------- Coquille de l'application ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--gs-sidebar-bg);
  color: var(--gs-sidebar-fg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1040;
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-logo { width: 40px; height: 40px; font-size: .95rem; border-radius: .65rem; }
.brand-logo-img { width: 42px; height: 42px; object-fit: contain; border-radius: .5rem; }
.topbar-logo { height: 32px; width: auto; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; color: #fff; }
.brand-text small { color: #94a3b8; font-size: .7rem; }
.sidebar-nav { flex: 1; padding: .75rem .5rem; }
.nav-group-title {
  text-transform: uppercase; font-size: .66rem; letter-spacing: .08em;
  color: #64748b; padding: .75rem 1rem .35rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .65rem;
  color: var(--gs-sidebar-fg);
  text-decoration: none; padding: .55rem .9rem;
  border-radius: .5rem; margin: 1px 0;
  font-size: .88rem;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: var(--gs-sidebar-active); color: #fff; }
.sidebar-link i { font-size: 1rem; width: 1.2rem; text-align: center; }
.sidebar-footer { padding: .75rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: .6rem; color: #e2e8f0; }
.sidebar-user small { color: #94a3b8; display: block; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gs-primary), var(--gs-accent));
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: .75rem; }

.main-area {
  flex: 1;
  margin-left: 260px;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--gs-card-border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem;
  position: sticky; top: 0; z-index: 1030;
}
.topbar-search { flex: 1; max-width: 460px; }
.topbar-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.topbar-clock { color: var(--gs-text-muted); font-size: .85rem; }
.main-content { padding: 1.5rem; flex: 1; }
.sidebar-backdrop { display: none; }

/* ---------- Cartes & statistiques ---------- */
.card { border-color: var(--gs-card-border); box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; border: 1px solid var(--gs-card-border); border-radius: .9rem; background: #fff; height: 100%; }
.stat-icon { width: 52px; height: 52px; border-radius: .9rem; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: #fff; flex-shrink: 0; }
.stat-primary { background: linear-gradient(135deg, #2563eb, #38bdf8); }
.stat-success { background: linear-gradient(135deg, #16a34a, #4ade80); }
.stat-warning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-danger { background: linear-gradient(135deg, #dc2626, #fb7185); }
.stat-info { background: linear-gradient(135deg, #0891b2, #22d3ee); }
.stat-violet { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--gs-text-muted); font-size: .82rem; }
.stat-sub { color: var(--gs-text-muted); font-size: .75rem; }

.page-heading { margin-bottom: 1.25rem; }

/* ---------- Tableaux ---------- */
.table { margin-bottom: 0; }
.table thead th {
  background: #f8fafc; color: var(--gs-text-muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; border-bottom-width: 1px;
}
.table tbody td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }
.badge-soft { font-weight: 500; font-size: .74rem; }

/* ---------- POS ---------- */
.pos-layout { display: grid; grid-template-columns: minmax(0,1fr) 460px; gap: 1rem; }
@media (max-width: 992px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-products { max-height: 70vh; overflow-y: auto; }
.pos-results-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: .75rem; }
.pos-search-card .form-control-lg { font-size: 1.05rem; }
.pos-card {
  border: 1px solid var(--gs-card-border); border-radius: .8rem;
  padding: .85rem; background: #fff; cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  position: relative;
}
.pos-card:hover { border-color: var(--gs-primary); box-shadow: 0 4px 12px rgba(37,99,235,.15); }
.pos-card .stock-badge {
  position: absolute; top: .6rem; right: .6rem; font-size: .7rem;
}
.pos-card h6 { margin-bottom: .15rem; font-size: .85rem; }
.pos-card .price { color: var(--gs-primary); font-weight: 700; }

/* ---------- Divers ---------- */
.alert { border-radius: .6rem; }
.btn { border-radius: .55rem; }
.form-control, .form-select { border-radius: .55rem; font-size: .9rem; }
.input-group-text { border-radius: .55rem; }
.dropdown-menu { border-radius: .7rem; box-shadow: 0 10px 30px rgba(15,23,42,.15); }
.chart-box { position: relative; height: 300px; }
.badge-total { font-size: 1rem; }

/* Impression */
@media print {
  .sidebar, .topbar, .no-print, .sidebar-backdrop { display: none !important; }
  .main-area { margin: 0 !important; }
  .main-content { padding: 0 !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc; }
}

/* Responsive */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
  .main-area { margin-left: 0; }
  .topbar-search { max-width: 260px; }
}

/* Invoice A4 preview */
.invoice-sheet {
  background: #fff; max-width: 800px; margin: 0 auto;
  border: 1px solid var(--gs-card-border); padding: 2rem;
  font-size: .85rem;
}
.invoice-sheet h4 { margin-bottom: 0; }
.invoice-meta td { padding: .15rem .35rem; }