/* ============================================================
   style.css — Factura v1.0.0
   Mobile-first, PWA, sans dépendances
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --blue:        #1e40af;
  --blue-mid:    #2563eb;
  --blue-light:  #3b82f6;
  --blue-pale:   #eff6ff;
  --blue-border: #bfdbfe;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
  --gray-400:    #94a3b8;
  --gray-500:    #64748b;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-800:    #1e293b;
  --gray-900:    #0f172a;
  --green:       #16a34a;
  --green-pale:  #f0fdf4;
  --green-border:#bbf7d0;
  --red:         #dc2626;
  --red-pale:    #fef2f2;
  --red-border:  #fecaca;
  --orange:      #ea580c;
  --orange-pale: #fff7ed;
  --yellow:      #ca8a04;
  --yellow-pale: #fefce8;

  --sidebar-w:   240px;
  --header-h:    56px;
  --bottom-nav-h:60px;
  --radius:      10px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,.12);
  --transition:  .18s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Utilitaires ───────────────────────────────────────────── */
.hidden { display: none !important; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-500); }
.text-warning { color: var(--orange); font-weight: 600; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Login Screen ──────────────────────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .logo-icon {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 8px;
}
.login-logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -.5px;
}
.login-logo p {
  font-size: .85rem;
  color: var(--gray-500);
  margin-top: 2px;
}

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

/* ── Sidebar (desktop) ─────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand .brand-ver {
  font-size: .7rem;
  color: var(--gray-400);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-section-title {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
  padding: 14px 18px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--gray-400);
  font-size: .9rem;
  border-radius: 0;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(59,130,246,.18);
  color: var(--blue-light);
  font-weight: 600;
}
.nav-item .nav-icon { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 12px 0;
}

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

/* ── Page Header ───────────────────────────────────────────── */
#page-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-800);
}
.header-actions { display: flex; gap: 8px; align-items: center; }
#global-search-btn:hover { opacity: .7; }

/* ── Recherche globale ───────────────────────────────────────── */
.search-result-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background .12s;
}
.search-result-item:hover { background: var(--gray-50); }
.search-result-item:last-child { border-bottom: none; }

/* ── Page Content ──────────────────────────────────────────── */
#page-content {
  flex: 1;
  padding: 24px;
  max-width: 1100px;
  width: 100%;
}

/* ── Boutons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover { background: #1e3a8a; border-color: #1e3a8a; }
.btn-outline {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-danger {
  background: var(--red-pale);
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover { background: #fecaca; }
.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 12px; font-size: .8rem; border-radius: 6px; }
.btn-icon { padding: 8px; border-radius: 8px; background: none; border: 1.5px solid var(--gray-200); color: var(--gray-600); }
.btn-icon:hover { background: var(--gray-100); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }

/* ── Formulaires ───────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--gray-800);
  background: #fff;
  transition: border var(--transition);
  outline: none;
  appearance: none;
}
.form-control:focus { border-color: var(--blue-light); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.form-control::placeholder { color: var(--gray-400); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { 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 d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-hint { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }
.form-error { font-size: .78rem; color: var(--red); margin-top: 4px; }

/* ── Lignes facture/devis ───────────────────────────────────── */
/* Desktop : grille à 6 colonnes définie en inline style        */
/* .ligne-fields-row + .ligne-field-wrap transparents (display:contents) */
/* pour que les inputs participent à la grille parent           */
.ligne-fields-row { display: contents; }
.ligne-field-wrap { display: contents; }
.ligne-field-label, .ligne-ac-label { display: none; } /* cachés sur desktop */

/* ── Autocomplete article (lignes facture/devis) ────────────── */
.ligne-ac-wrap { position: relative; }
.ligne-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--blue-border);
  border-radius: 0 0 8px 8px;
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.ligne-drop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  font-size: .82rem;
  gap: 8px;
}
.ligne-drop-item:last-child { border-bottom: none; }
.ligne-drop-item:hover, .ligne-drop-item.hovered { background: var(--blue-pale); }
.ligne-drop-nom { font-weight: 600; color: var(--gray-800); }
.ligne-drop-meta { font-size: .72rem; color: var(--gray-400); }
.ligne-drop-prix { font-weight: 700; color: var(--blue); white-space: nowrap; }
.ligne-drop-empty { padding: 10px 12px; font-size: .82rem; color: var(--gray-400); font-style: italic; }

/* ── Cartes ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--gray-800);
}
.card-body { padding: 20px; }

/* ── KPI Cards (Dashboard) ─────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1.1;
}
.kpi-value.blue { color: var(--blue); }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }
.kpi-value.orange { color: var(--orange); }
.kpi-sub {
  font-size: .78rem;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
td {
  padding: 11px 14px;
  color: var(--gray-700);
  vertical-align: middle;
}
td.actions { white-space: nowrap; text-align: right; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-gray     { background: var(--gray-100); color: var(--gray-600); }
.badge-blue     { background: var(--blue-pale); color: var(--blue); }
.badge-green    { background: var(--green-pale); color: var(--green); }
.badge-red      { background: var(--red-pale); color: var(--red); }
.badge-orange   { background: var(--orange-pale); color: var(--orange); }
.badge-yellow   { background: var(--yellow-pale); color: var(--yellow); }

/* ── Search Bar ────────────────────────────────────────────── */
.search-bar {
  position: relative;
  max-width: 320px;
}
.search-bar input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .875rem;
  outline: none;
  transition: border var(--transition);
  background: var(--gray-50);
}
.search-bar input:focus { border-color: var(--blue-light); background: #fff; }
.search-bar .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: .9rem;
  pointer-events: none;
}

/* ── Toolbar (between header and table) ───────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; margin-bottom: 16px; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-info    { background: var(--blue-pale); color: var(--blue); border: 1px solid var(--blue-border); }
.alert-success { background: var(--green-pale); color: var(--green); border: 1px solid var(--green-border); }
.alert-error   { background: var(--red-pale); color: var(--red); border: 1px solid var(--red-border); }
.alert-warning { background: var(--yellow-pale); color: var(--yellow); border: 1px solid #fde047; }

/* ── Toast ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: 24px;
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
  background: var(--gray-800);
  box-shadow: var(--shadow-md);
  animation: toast-in .2s ease;
  pointer-events: auto;
  max-width: 320px;
  text-align: center;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
.toast.info    { background: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Modal ─────────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: modal-in .18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.2rem; color: var(--gray-400); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Loader ────────────────────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
  display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  text-align: center;
  padding: 48px;
  color: var(--gray-400);
  font-size: .875rem;
}

/* ── Puce stock ─────────────────────────────────────────────── */
.stock-ok    { color: var(--green); }
.stock-alert { color: var(--orange); }
.stock-zero  { color: var(--red); }

/* ── Page form card ─────────────────────────────────────────── */
.form-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 680px;
}
.form-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-100);
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
}

/* ── Bottom Nav (mobile) ───────────────────────────────────── */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: #fff;
  border-top: 1px solid var(--gray-200);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: flex;
  height: 100%;
}
.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--gray-400);
  font-size: .65rem;
  font-weight: 600;
  padding: 4px 0;
  transition: color var(--transition);
  cursor: pointer;
}
.bnav-item .bnav-icon { font-size: 1.2rem; }
.bnav-item.active { color: var(--blue); }
.bnav-item-plus {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
}
.bnav-plus-btn {
  width: 46px;
  height: 46px;
  background: var(--blue);
  color: #fff;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 300;
  box-shadow: 0 4px 12px rgba(30,64,175,.35);
  transition: transform .15s, background .15s;
}
.bnav-plus-btn.open {
  transform: rotate(45deg);
  background: var(--red);
}
.fab-menu {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
  overflow: hidden;
  z-index: 300;
  min-width: 200px;
  animation: fabIn .18s ease;
}
@keyframes fabIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.fab-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .92rem;
  font-weight: 600;
  color: var(--gray-800);
  text-align: left;
  transition: background .12s;
}
.fab-menu-item:not(:last-child) { border-bottom: 1px solid var(--gray-100); }
.fab-menu-item:hover { background: var(--blue-pale); color: var(--blue); }
.fab-menu-icon { font-size: 1.2rem; }

/* ── Sidebar Drawer (mobile) ───────────────────────────────── */
/* Backdrop semi-transparent derrière la sidebar ouverte */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  backdrop-filter: blur(1px);
  -webkit-backdrop-filter: blur(1px);
}
#sidebar-backdrop.open { display: block; }

/* Bouton hamburger (visible uniquement sur mobile) */
#sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
  color: var(--gray-700);
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition);
}
#sidebar-toggle:hover { background: var(--gray-50); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Sidebar : transformée en drawer slide-in */
  #sidebar {
    display: flex !important; /* toujours dans le DOM */
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-toggle { display: flex; }
  #main { margin-left: 0; padding-bottom: var(--bottom-nav-h); }
  #bottom-nav { display: block; }
  #page-content { padding: 16px; }
  #page-header { padding: 0 12px; gap: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 1.2rem; }
  .form-card { padding: 20px 16px; }
  #toast-container { bottom: calc(var(--bottom-nav-h) + 12px); left: 16px; right: 16px; transform: none; }
  thead { display: none; }
  tbody tr { display: block; padding: 12px 16px; }
  td { display: flex; justify-content: space-between; padding: 4px 0; border: none; font-size: .85rem; }
  td::before { content: attr(data-label); font-weight: 600; color: var(--gray-500); font-size: .78rem; flex-shrink: 0; margin-right: 8px; }
  td.actions { justify-content: flex-end; padding-top: 8px; }

  /* Lignes facture/devis — layout mobile */
  .ligne-row {
    display: block !important;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
  }
  .ligne-row .ligne-ac-wrap { margin-bottom: 8px; }
  .ligne-fields-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr 56px 60px 28px;
    gap: 6px;
    align-items: end;
  }
  .ligne-fields-row input,
  .ligne-fields-row select {
    font-size: .8rem !important;
    padding: 6px 6px !important;
  }
  /* Labels visibles sur mobile */
  .ligne-field-label { display: block; font-size: .68rem; color: var(--gray-500,#64748b); margin-bottom: 2px; font-weight: 600; }
  .ligne-ac-label    { display: block; font-size: .68rem; color: var(--gray-500,#64748b); margin-bottom: 2px; font-weight: 600; }
  .ligne-field-wrap  { display: flex; flex-direction: column; }
  .ligne-btn-del     { margin-top: 18px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  #page-content { padding: 20px; }
}

@media (min-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  #sidebar, #bottom-nav, #page-header, .btn, .toolbar { display: none !important; }
  #main { margin: 0; }
  #page-content { padding: 0; }
}
