/* ════════════════════════════════════════════════════════════════
   PCT Stock Scan — design épuré professionnel
   Mobile-first (PDA 4" ~360px), s'adapte sur desktop.
   ════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

/* Force le respect de l'attribut hidden même sur les éléments avec display:flex/grid */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* ─── Header ─── */
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
}
header h1 {
  flex: 1; margin: 0;
  font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.header-right {
  display: flex; align-items: center; gap: 8px;
}
.icon-btn {
  background: transparent; border: 0;
  font-size: 22px; cursor: pointer;
  color: var(--text); padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.icon-btn:active { background: var(--bg); }
.pill {
  font-size: 13px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.company-select {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  max-width: 140px;
}

main {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ─── Screens ─── */
.screen { animation: fadeIn 180ms ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.section-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 8px 4px 12px;
}

/* ─── Cards ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.card.centered { text-align: center; }

/* ─── Brand ─── */
.brand { margin-bottom: 24px; }
.brand-logo {
  width: 72px; height: 72px;
  border-radius: 16px;
  margin-bottom: 12px;
}
.brand h2 { margin: 8px 0 4px; font-size: 22px; font-weight: 600; }
.brand p { margin: 0; }

/* ─── Forms ─── */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--text-muted);
  text-align: left;
}
.form label em { font-style: normal; color: var(--text); font-weight: 600; }
.form input, .form select {
  font: inherit; font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 120ms, box-shadow 120ms;
  width: 100%;
}
.form input:focus, .form select:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ─── Buttons ─── */
.btn {
  font: inherit; font-size: 15px; font-weight: 500;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, transform 120ms;
  white-space: nowrap;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:active { transform: scale(0.98); }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.block { width: 100%; }
.btn.small { font-size: 13px; padding: 8px 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Tile grid ─── */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 12px;
  text-align: center;
  cursor: pointer;
  font: inherit; color: var(--text);
  transition: border-color 120ms, transform 120ms, box-shadow 120ms;
}
.tile:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.tile:active { transform: scale(0.97); }
.tile-icon { font-size: 36px; margin-bottom: 8px; }
.tile-label { font-size: 16px; font-weight: 600; }
.tile-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Scan summary ─── */
.scan-summary .row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}
.scan-summary .row + .row { border-top: 1px solid var(--border); }

/* ─── Scan input bar ─── */
.scan-input-row {
  display: grid;
  grid-template-columns: 1fr 80px auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
}
.scan-input-row input {
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.scan-input-row input:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
#scan-input { font-family: 'Courier New', monospace; }
#btn-add-scan { padding: 10px 14px; }

.scan-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin: 8px 4px 12px;
}

/* ─── Caméra : overlay plein écran avec viseur ─── */
.camera-zone {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-zone[hidden] { display: none; }
.camera-zone video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background:
    /* Assombrit l'extérieur du viseur */
    radial-gradient(ellipse 80% 35% at center,
      transparent 0%,
      transparent 49%,
      rgba(0,0,0,0.55) 51%);
}
.camera-viewfinder {
  position: relative;
  width: min(80vw, 360px);
  height: min(28vh, 180px);
  border-radius: 12px;
}
.camera-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
  border-radius: 4px;
}
.camera-corner.tl { top: -2px; left: -2px;
  border-right: none; border-bottom: none;
  border-top-left-radius: 12px; }
.camera-corner.tr { top: -2px; right: -2px;
  border-left: none; border-bottom: none;
  border-top-right-radius: 12px; }
.camera-corner.bl { bottom: -2px; left: -2px;
  border-right: none; border-top: none;
  border-bottom-left-radius: 12px; }
.camera-corner.br { bottom: -2px; right: -2px;
  border-left: none; border-top: none;
  border-bottom-right-radius: 12px; }
.camera-laser {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%, #ff3b30 20%, #ff3b30 80%, transparent 100%);
  box-shadow: 0 0 8px #ff3b30;
  animation: laser-scan 1.6s ease-in-out infinite;
}
@keyframes laser-scan {
  0%, 100% { transform: translateY(-60px); opacity: 0.6; }
  50%      { transform: translateY(60px);  opacity: 1; }
}
.camera-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}
.camera-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.camera-close:hover { background: rgba(0,0,0,0.85); }
.small { font-size: 12px; }

/* ─── Liste articles scannés ─── */
.scan-list {
  list-style: none;
  margin: 0 0 100px;
  padding: 0;
}
.scan-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  animation: slideIn 200ms ease-out;
}
.scan-list li.unknown { border-color: var(--danger); background: var(--danger-soft); }
.scan-list li.just-added { animation: pulse 400ms ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  100% { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
}

.item-info { display: flex; flex-direction: column; min-width: 0; }
.item-caption {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-barcode {
  font-family: 'Courier New', monospace;
  font-size: 12px; color: var(--text-muted);
}
.item-warning { font-size: 12px; color: var(--danger); margin-top: 2px; }
.item-qty {
  width: 64px;
  font-size: 16px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: right;
  font-weight: 600;
}
.item-qty:focus { outline: 0; border-color: var(--primary); }
.item-remove {
  background: transparent; border: 0;
  color: var(--danger); font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.item-remove:hover { background: var(--danger-soft); }

/* ─── Bottom bar ─── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex; gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(15, 23, 42, 0.04);
}
.bottom-bar .btn { flex: 1; }
.bottom-bar .btn.primary { flex: 2; }
.bottom-bar.three-cols .btn { flex: 1; font-size: 14px; padding: 12px 8px; }
.bottom-bar.three-cols .btn.primary { flex: 1.6; }

/* ─── Success ─── */
.big-emoji { font-size: 64px; }
.success-card { padding: 32px 16px; }
.doc-number {
  font-family: 'Courier New', monospace;
  font-size: 22px; font-weight: 700;
  color: var(--success);
  background: var(--success-soft);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 8px 0 24px;
  letter-spacing: 0.04em;
}

/* ─── Historique ─── */
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.history-meta {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-muted);
}
.history-doc {
  font-family: 'Courier New', monospace;
  font-weight: 600;
}
.history-status {
  font-size: 12px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  align-self: flex-start;
}
.history-status.validated   { color: var(--success); background: var(--success-soft); }
.history-status.in-progress { color: var(--warning); background: var(--warning-soft); }
.history-status.cancelled   { color: var(--text-muted); background: var(--bg); }

/* ─── Helpers ─── */
.muted { color: var(--text-muted); }
.error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

/* ─── Bandeau lecture seule (BS généré) ─── */
.readonly-banner {
  background: var(--success-soft);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 0 4px 12px;
  font-size: 14px;
}
.readonly-banner strong { font-size: 15px; }
.readonly-banner .muted {
  display: block;
  margin-top: 2px;
  color: #166534;
  font-weight: normal;
}

/* ─── Bouton supprimer un BS dans la liste ─── */
.bs-delete {
  position: absolute;
  top: 8px; right: 8px;
  background: transparent;
  border: 0;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 80ms;
}
.bs-delete:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.history-list li {
  position: relative;     /* nécessaire pour positionner le bouton supprimer */
  padding-right: 48px;    /* laisse de la place au bouton */
}

/* ─── Header de liste (Bons de Sortie, etc.) ─── */
.list-header {
  display: flex; justify-content: space-between; align-items: center;
  margin: 8px 4px 12px;
  gap: 12px;
}
.list-header .section-title { margin: 0; }

/* ─── Modal article picker ─── */
/* Mobile : bottom sheet (par défaut). Desktop : centré. */
.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 180ms ease-out;
}
.modal-card {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.2);
  animation: slideUp 220ms ease-out;
}

/* Desktop : on centre, coins arrondis sur les 4 côtés */
@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 16px;
  }
  .modal-card {
    border-radius: var(--radius);
    max-height: min(80vh, 720px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    animation: slideDown 220ms ease-out;
  }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes slideDown {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-search {
  font: inherit; font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
}
.modal-search:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.picker-list {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto;
  flex: 1;
}
.picker-list li {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 80ms;
}
.picker-list li:hover,
.picker-list li:active { background: var(--primary-soft); }
.picker-list li:last-child { border-bottom: 0; }
.picker-item-caption { font-weight: 600; }
.picker-item-meta {
  font-size: 12px; color: var(--text-muted);
  font-family: 'Courier New', monospace;
  margin-top: 2px;
}
.line-panel {
  border: 2px solid var(--primary);
  background: var(--primary-soft);
  animation: slideIn 180ms ease-out;
}
.line-panel-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.line-panel-title span {
  font-weight: 600; font-size: 16px;
}
.line-panel-article {
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.line-panel .form label textarea,
.line-panel .form label select,
.line-panel .form label input {
  font: inherit; font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  resize: vertical;
}
.line-panel-actions {
  display: flex; gap: 8px;
  margin-top: 16px;
}
.line-panel-actions .btn { flex: 1; }

textarea#ctx-reference {
  font: inherit; font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  resize: vertical;
}
textarea#ctx-reference:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ─── Métadonnées ligne (lot/emplacement dans la liste) ─── */
.item-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 12px;
  margin-top: 4px;
}
.item-meta .chip {
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--text-muted);
}
.item-meta .chip.dlu { color: var(--warning); background: var(--warning-soft); }

.item-edit {
  background: transparent; border: 0;
  color: var(--text-muted); font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.item-edit:hover { background: var(--bg); color: var(--primary); }
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 100;
  box-shadow: var(--shadow);
  max-width: 90%;
  animation: toastIn 200ms ease-out;
}
.toast.error   { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translateX(-50%); }
}

/* ─── Toast (fin de fichier, reposé après les blocs ajoutés) ─── */

/* ─── Paramétrage ─── */
.settings-section {
  margin-bottom: 16px;
}
.settings-section.disabled {
  opacity: 0.55;
}
.settings-section h3 {
  font-size: 16px;
  margin: 0 0 8px;
  font-weight: 600;
}
.settings-section .small {
  font-size: 13px;
  margin: 4px 0 0;
}
.settings-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.settings-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--surface);
}
.settings-list li.inactive {
  opacity: 0.5;
}
.user-main { flex: 1; min-width: 0; }
.user-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}
.user-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.user-login {
  font-family: var(--font-mono, monospace);
  background: var(--surface-alt, #f1f5f9);
  padding: 1px 6px;
  border-radius: 4px;
}
.user-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-alt, #f1f5f9);
  color: var(--text-muted);
}
.user-badge.admin {
  background: var(--primary-soft, #eef2ff);
  color: var(--primary);
}
.user-badge.inactive {
  background: var(--danger-soft);
  color: var(--danger);
}
.user-actions {
  display: flex;
  gap: 4px;
}

/* Checkbox + label inline (modale création user) */
.checkbox-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}
.checkbox-row span {
  font-size: 14px;
  color: var(--text);
}

/* Disabled checkbox = grisé */
.checkbox-row input[type="checkbox"]:disabled + span {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Header buttons : 🏠 et ⚙️ déjà couverts par .icon-btn existant */

/* ─── Inventaire : affichage stock théorique + écart ─── */
.delta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  margin: -4px 4px 4px;                  /* collé sous le champ qté */
  background: var(--surface-alt, #f1f5f9);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.delta-label {
  color: var(--text-muted);
}
.delta-label strong {
  color: var(--text);
  font-weight: 600;
}
.delta-separator {
  color: var(--text-muted);
  font-size: 16px;
}
.delta-value {
  font-weight: 700;
  font-size: 16px;
  padding: 2px 8px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.delta-value.zero     { background: #e5e7eb; color: #374151; }
.delta-value.positive { background: var(--success-soft); color: var(--success); }
.delta-value.negative { background: var(--danger-soft);  color: var(--danger); }

/* ─── Transfert : chip emplacement destination ─── */
.chip.dest {
  background: var(--primary-soft, #eef2ff);
  color: var(--primary);
  border-color: var(--primary);
}

/* ─── KPI accueil : en attente de transfert vers EBP ─── */
.kpi-card {
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.18);
}
.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.kpi-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.kpi-subtitle {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
}
.kpi-total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
}
.kpi-total-value,
#kpi-total-value {
  font-size: 38px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.kpi-total-label {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-breakdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.kpi-item {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  color: #fff;
  cursor: pointer;
  transition: background 120ms, transform 120ms;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.kpi-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}
.kpi-item:disabled {
  opacity: 0.45;
  cursor: default;
}
.kpi-item-icon {
  font-size: 18px;
}
.kpi-item-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-item-label {
  font-size: 11px;
  opacity: 0.9;
}

/* ─── Paramétrage EBP : formulaire ─── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}
.subsection-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 18px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.shortcut-row {
  display: grid;
  grid-template-columns: minmax(120px, auto) 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.shortcut-company {
  font-size: 14px;
  font-weight: 500;
}
.shortcut-input {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.success-msg {
  background: var(--success-soft);
  color: var(--success);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 8px;
}

/* ─── Gestion d'erreur d'export EBP ─── */
.history-list li.has-error {
  border-left: 4px solid var(--danger);
  padding-left: 12px;
}
.history-status.error {
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
  border: 1px solid var(--danger);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background 120ms;
}
.history-status.error:hover {
  background: var(--danger);
  color: #fff;
}

/* Modale plus large pour afficher les outputs EBP */
.modal-card.wide {
  max-width: 760px;
}
.modal-body {
  padding: 4px 0 8px;
}
.error-meta {
  background: var(--surface-alt, #f1f5f9);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 12px;
}
.error-meta code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12px;
  background: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  word-break: break-all;
}
.error-output {
  background: #0f172a;
  color: #f1f5f9;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 40vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 12px;
}

/* ─── Champ avec bouton d'action à droite (ex: scan lot) ─── */
.input-with-action {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.input-with-action input {
  flex: 1;
  min-width: 0;
}
.input-action-btn {
  flex: 0 0 auto;
  width: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.input-action-btn:hover {
  background: var(--primary-soft, #eef2ff);
  border-color: var(--primary);
}
.input-action-btn:active {
  transform: scale(0.95);
}

/* ─── Préférences personnelles : toggle label ─── */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
}
.toggle-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  cursor: pointer;
}
.toggle-label span {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

/* ─── Bandeau "Nouvelle version disponible" ─── */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9998;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  animation: slideDown 200ms ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}
.update-banner .btn {
  flex-shrink: 0;
}
.update-banner .btn.primary {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
}
.update-banner .btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* ─── Section À propos : version info ─── */
.version-info {
  background: var(--surface-alt, #f1f5f9);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
}
.version-info strong {
  font-weight: 600;
}

/* ─── Bouton "Clavier" en mode actif (saisie clavier ON) ─── */
.btn.ghost.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ─── Section Branding (preview logo) ─── */
.branding-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--surface-alt, #f8fafc);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin: 8px 0 12px;
}
.branding-preview-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
