:root, html[data-theme="light"] {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #6b778c;
  --border: #e3e8ef;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.04);
  --radius: 12px;
  --topbar-bg: #f4f6f9;
  --topbar-text: #1a2332;
  --topbar-muted: #6b778c;
  --code-bg: #eef2f7;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f1419;
  --card: #1a222d;
  --text: #e8ecf4;
  --muted: #9aa3b5;
  --border: #2a3544;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --danger: #f87171;
  --ok: #4ade80;
  --orange: #fb923c;
  --red: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);
  --topbar-bg: #000000;
  --topbar-text: #f3f5f9;
  --topbar-muted: #8b93a7;
  --code-bg: #243041;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code { font-size: 0.9em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.5rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  color: var(--topbar-text);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .muted { color: var(--topbar-muted); }
.topbar-version { color: var(--topbar-muted) !important; font-size: 0.8rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.btn-theme {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid color-mix(in srgb, var(--topbar-text) 25%, transparent);
  background: transparent;
  color: var(--topbar-text);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-theme:hover { background: color-mix(in srgb, var(--topbar-text) 12%, transparent); }
html[data-theme="light"] .theme-icon-moon { display: inline; }
html[data-theme="light"] .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: inline; }
.brand { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.brand-logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}
.brand-logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
}
html[data-theme="light"] .brand-logo-dark { display: none; }
html[data-theme="light"] .brand-logo-light { display: block; }
html[data-theme="dark"] .brand-logo-light { display: none; }
html[data-theme="dark"] .brand-logo-dark { display: block; }
.brand-text strong {
  display: block;
  font-size: 1.05rem;
  color: var(--topbar-text);
  letter-spacing: 0.01em;
}
.brand-text .muted { margin-top: 0.1rem; }
.logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #2e3b68, #4a5a8a);
  color: white; display: grid; place-items: center; font-weight: 700;
}
.muted { color: var(--muted); font-size: 0.85rem; }
.small { font-size: 0.8rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.tabs { display: flex; gap: 0.35rem; }
.tabs a {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}
.tabs a.active, .tabs a:hover {
  background: #eef4ff;
  color: var(--primary);
}

.container { max-width: 1200px; margin: 1.25rem auto; padding: 0 1.25rem 2rem; }
.footer { text-align: center; padding: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
.header-card { margin-bottom: 1rem; }
.header-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
}
.label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.2rem; }
.value { font-size: 1.05rem; font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn-ghost { background: #f8fafc; }
.btn-link { border: none; background: transparent; color: var(--muted); }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.badge {
  display: inline-flex; align-items: center;
  padding: 0.25rem 0.65rem; border-radius: 999px;
  font-size: 0.82rem; font-weight: 700;
}
.badge-en_cours { background: #eef4ff; color: #1d4ed8; }
.badge-en_attente { background: #fff7ed; color: #c2410c; }
.badge-validee { background: #ecfdf5; color: #047857; }
.badge-probleme { background: #fef2f2; color: #b91c1c; }

.layout-2 {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 1rem;
}
h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.hint { margin: 0 0 0.9rem; color: var(--muted); font-size: 0.88rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right !important; }
.article { font-weight: 600; }

.inline { display: flex; gap: 0.35rem; align-items: center; justify-content: flex-end; }
.qty {
  width: 4.5rem; padding: 0.35rem 0.45rem;
  border: 1px solid var(--border); border-radius: 6px;
  text-align: right;
}

.pill {
  display: inline-flex; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
}
.pill-ok { background: #ecfdf5; color: var(--ok); }
.pill-manquant { background: #fef2f2; color: var(--red); }
.pill-partiel { background: #fff7ed; color: var(--orange); }
.pill-hors_commande { background: #f1f5f9; color: #475569; }
.pill-orange { background: #fff7ed; color: var(--orange); }
.pill-red { background: #fef2f2; color: var(--red); }

.row-manquant { background: #fffafa; }
.row-partiel { background: #fffaf5; }
.row-hors_commande { background: #f8fafc; }

.preview .pdf-frame {
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafbfc;
  overflow: hidden;
  min-height: 320px;
  display: grid;
  place-items: center;
}
.preview img { width: 100%; height: auto; display: block; }

.flash {
  background: #eef4ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

@media (max-width: 960px) {
  .header-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-2 { grid-template-columns: 1fr; }
}

/* aliases used by templates */
.header-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.btn-ghost { background: #f8fafc; }
.btn-link { border: none; background: transparent; color: var(--muted); text-decoration: underline; cursor: pointer; }
.pdf-frame {
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafbfc;
  overflow: hidden;
  min-height: 320px;
  display: grid;
  place-items: center;
}
.pdf-frame img { width: 100%; height: auto; display: block; }
.pill-partiel { background: #fff7ed; color: var(--orange); }
.pill-hors_commande { background: #f1f5f9; color: #475569; }
.row-partiel { background: #fffaf5; }
.row-hors_commande { background: #f8fafc; }
.badge-en_cours { background: #eef4ff; color: #1d4ed8; }
.badge-en_attente { background: #fff7ed; color: #c2410c; }
.badge-validee { background: #ecfdf5; color: #047857; }
.badge-probleme { background: #fef2f2; color: #b91c1c; }

/* Empty / disabled state (production-like lab) */
.value.empty { color: var(--muted); font-weight: 500; }
.badge-vide { background: #f1f5f9; color: #475569; }
.btn:disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.empty-state {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem 1.25rem;
  background: #fafbfc;
  text-align: center;
}
.empty-preview {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}
.flash-wait {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* Sélection commandes Odoo */
.commandes-card {
  margin-bottom: 1rem;
}
.commandes-card-prominent {
  border-color: #bfdbfe;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08), 0 6px 16px rgba(37, 99, 235, 0.08);
}
.commandes-card-assign {
  border-color: #fbbf24;
  box-shadow: 0 1px 2px rgba(180, 83, 9, 0.08), 0 6px 16px rgba(245, 158, 11, 0.12);
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 42%);
}
.commandes-exact-flash {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin: 0.65rem 0 0.85rem;
}
.commandes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}
.commandes-head h2 { margin-bottom: 0.15rem; }
.commandes-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.commandes-search input[type="search"] {
  min-width: 16rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
}
.commandes-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.commandes-table { margin: 0; }
.commandes-table th:last-child,
.commandes-table td:last-child { text-align: right; white-space: nowrap; }
.commandes-table .row-selected { background: #eef4ff; }
.commandes-error { margin: 0.5rem 0 0.75rem; }
.pill-receipt-pending { background: #fff7ed; color: var(--orange); }
.pill-receipt-partial { background: #eef4ff; color: #1d4ed8; }
.pill-receipt-full { background: #ecfdf5; color: var(--ok); }

@media (max-width: 960px) {
  .commandes-search input[type="search"] { min-width: 100%; width: 100%; }
}

/* Boîte mail reception@catsnet.fr */
.mail-card { margin-bottom: 1rem; }
.mail-status-pills { display: flex; gap: 0.4rem; align-items: center; }
.mail-table td { font-size: 0.9rem; }
.mail-table .small { font-size: 0.8rem; }

.mail-device-panel {
  border: 1px solid #bfdbfe;
  background: #f8fbff;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin: 0.5rem 0 0.85rem;
}
.mail-device-title { margin: 0 0 0.35rem; }
.mail-user-code {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #1d4ed8;
}

/* Import PDF manuel (secours, replié) */
.upload-card { margin-bottom: 0.75rem; }

/* Import manuel en <details> (v0.7.7) */
details.upload-details {
  border-style: dashed;
  opacity: 0.98;
  padding-top: 0.65rem;
  padding-bottom: 0.65rem;
}
details.upload-details > summary.upload-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.1rem 0;
}
details.upload-details > summary.upload-summary::-webkit-details-marker { display: none; }
details.upload-details > summary.upload-summary::before {
  content: "▸";
  display: inline-block;
  width: 1rem;
  color: #64748b;
  transition: transform 0.15s ease;
  margin-top: 0.1rem;
}
details.upload-details[open] > summary.upload-summary::before { transform: rotate(90deg); }
.upload-summary-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: #334155;
}
.upload-summary .hint {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
}
.upload-details-body { margin-top: 0.65rem; }

/* legacy primary (si réutilisé) */
.upload-card-primary { margin-bottom: 1rem; }
.upload-card-prominent {
  border-color: #93c5fd;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.1), 0 8px 20px rgba(37, 99, 235, 0.12);
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 48%);
}
.commandes-card-secondary {
  opacity: 0.98;
  border-style: dashed;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 0.35rem 0 0.5rem;
}
.upload-form input[type="file"] {
  flex: 1 1 16rem;
  padding: 0.45rem 0.5rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 0.9rem;
}
.pdf-iframe {
  width: 100%;
  min-height: 420px;
  border: 0;
  border-radius: 8px;
  background: #f1f5f9;
}


/* Dual BL + facture upload (v0.6.0) */
.upload-form-dual { display: flex; flex-direction: column; gap: 0.75rem; align-items: stretch; }
.upload-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 720px) { .upload-fields { grid-template-columns: 1fr; } }
.upload-field { display: flex; flex-direction: column; gap: 0.35rem; }
.upload-label { font-size: 0.9rem; font-weight: 600; }
.upload-label .req { color: #b45309; font-style: normal; font-weight: 500; font-size: 0.8rem; }
.upload-label .opt { color: #64748b; font-style: normal; font-weight: 500; font-size: 0.8rem; }
.pdf-previews { display: flex; flex-direction: column; gap: 1rem; }
.pdf-title { margin: 0 0 0.35rem; font-size: 0.95rem; }


/* Collapsible manual PO chooser (v0.6.1) */
details.commandes-details > summary.commandes-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.15rem 0;
}
details.commandes-details > summary.commandes-summary::-webkit-details-marker { display: none; }
details.commandes-details > summary.commandes-summary::before {
  content: "▸";
  display: inline-block;
  width: 1rem;
  color: #64748b;
  transition: transform 0.15s ease;
  margin-top: 0.15rem;
}
details.commandes-details[open] > summary.commandes-summary::before { transform: rotate(90deg); }
.commandes-summary-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: #0f172a;
}
.commandes-details-body { margin-top: 0.75rem; }
.commandes-details-body .commandes-search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.table-wrap { overflow-x: auto; }
.table-controle th, .table-controle td { white-space: nowrap; }
.table-controle td.col-article, .table-controle th.col-article { white-space: normal; min-width: 10rem; }
.table-controle th.col-select,
.table-controle td.col-select {
  width: 2.25rem;
  min-width: 2.25rem;
  max-width: 2.5rem;
  text-align: center;
  white-space: nowrap;
  padding-left: 0.5rem;
  padding-right: 0.35rem;
  vertical-align: middle;
}
.table-controle .line-select,
.table-controle #select-all-lines {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary, #2563eb);
  cursor: pointer;
}
.topbar-version { font-size: 0.8rem; margin-left: auto; align-self: center; }

.controle-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 0.5rem;
}
.controle-head h2 { margin-bottom: 0.25rem; }
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--text, #0f172a);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.filter-toggle input { accent-color: var(--primary, #2563eb); }

/* --- Modal n° de série --- */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none !important; }
.modal-dialog {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  width: min(32rem, 100%);
  max-height: min(85vh, 40rem);
  display: flex;
  flex-direction: column;
  border: 1px solid #e2e8f0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  color: #0f172a;
}
.modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}
.modal-close:hover { background: #f1f5f9; color: #0f172a; }
.modal-body {
  padding: 0.75rem 1.15rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem 1rem;
  border-top: 1px solid #f1f5f9;
}
.modal-error {
  margin: 0 1.15rem;
  padding: 0.5rem 0.75rem;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 0.9rem;
}
.sn-article-block { margin-bottom: 1rem; }
.sn-article-block:last-child { margin-bottom: 0.25rem; }
.sn-article-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
}
.sn-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.4rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.sn-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: #2563eb;
}

/* --- Modal résultat validation --- */
.modal-dialog-result { width: min(28rem, 100%); }
.result-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  padding-top: 0.5rem;
}
.result-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.result-icon-ok {
  background: #dcfce7;
  color: #15803d;
}
.result-icon-err {
  background: #fee2e2;
  color: #b91c1c;
}
.result-message {
  margin: 0;
  color: #0f172a;
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
#result-modal.result-ok .modal-header h2 { color: #15803d; }
#result-modal.result-err .modal-header h2 { color: #b91c1c; }

.line-select:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
tr.controle-row:has(.line-select:disabled) .article {
  opacity: 0.75;
}


.result-labels-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}
#result-modal-dymo {
  order: -1;
  margin-right: auto;
}
.result-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

/* --- Onglets multi-commandes (v0.7.0) --- */
.session-tabs {
  scroll-margin-top: 0.75rem;
  margin: 0 0 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.35rem 0.45rem;
}
.session-tabs-scroll {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 0.1rem;
}
.session-tab {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}
.session-tab.active {
  border-color: var(--primary);
  background: #eef4ff;
  box-shadow: inset 0 -2px 0 var(--primary);
}
.session-tab-activate { margin: 0; }
.session-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  padding: 0.4rem 0.55rem 0.4rem 0.7rem;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  white-space: nowrap;
}
.session-tab.active .session-tab-btn { color: var(--primary); font-weight: 600; }
.session-tab-label { font-size: 0.88rem; }
.session-tab-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.session-tab-close-form { margin: 0; display: flex; }
.session-tab-close {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0 0.45rem;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.session-tab-close:hover { color: var(--danger); background: #fef2f2; }


/* Multi-sélection mails (v0.7.4) */
.mail-multi-form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}
.mail-select-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin: 0.35rem 0 0.65rem;
}
.mail-select-all {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}
.mail-table .col-select {
  width: 2rem;
  text-align: center;
}
.mail-table input.mail-select {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}


/* --- Modal récap import (v0.7.6) --- */
.modal-dialog-import {
  width: min(36rem, 100%);
  max-height: min(85vh, 44rem);
}
.import-summary-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
  align-items: stretch;
  padding-top: 0.35rem;
}
.import-summary-section h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 650;
  color: #0f172a;
}
.import-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.import-summary-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  align-items: baseline;
  padding: 0.45rem 0.6rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.35;
}
.import-summary-list .is-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: #334155;
  word-break: break-all;
}
.import-summary-list .is-arrow {
  color: #94a3b8;
  font-weight: 600;
}
.import-summary-list .is-po {
  font-weight: 650;
  color: #15803d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.import-summary-list .is-warn {
  color: #b45309;
  font-weight: 600;
}
.import-summary-list .is-method {
  font-size: 0.75rem;
  color: #64748b;
  background: #e2e8f0;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
}
#import-summary-modal.result-ok .modal-header h2 { color: #15803d; }
#import-summary-modal.result-err .modal-header h2 { color: #b91c1c; }

/* Boîte mail = flux principal (v0.7.7) */
.mail-card {
  border-color: #93c5fd;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.08), 0 6px 16px rgba(37, 99, 235, 0.08);
}


/* Thème sombre — ajustements composants */
html[data-theme="dark"] .flash { background: #243041; border-color: #3a4a5e; }
html[data-theme="dark"] .flash-wait { background: #2a2418; border-color: #5c4a28; color: #f5e6c8; }
html[data-theme="dark"] .table thead th { background: #151c26; }
html[data-theme="dark"] .btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: #121820; color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.65); }
html[data-theme="dark"] .modal-dialog, html[data-theme="dark"] .modal-dialog-result {
  background: var(--card); color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] .session-tab { background: #151c26; border-color: var(--border); }
html[data-theme="dark"] .session-tab.active { background: #1e3a5f; border-color: var(--primary); }
html[data-theme="dark"] .pill-ok { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .empty-state { background: #151c26; }
@media (max-width: 640px) {
  .brand-text { display: none; }
  .theme-label { display: none; }
  .brand-logo { height: 40px; }
}


/* --- Quantités batch (v0.8.8) --- */
.controle-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.col-reel { white-space: nowrap; }
input.qty-reel.qty-dirty {
  outline: 2px solid #f59e0b;
  background: #fffbeb;
  border-color: #f59e0b;
}
.reels-status.reels-ok { color: #15803d; }
.reels-status.reels-error { color: #b91c1c; }

/* v0.9.2 — Facture non rattachée */
.facture-assign-card .facture-orphan {
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-top: 0.65rem;
  background: rgba(255, 251, 235, 0.6);
}
.facture-orphan-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: center; }
.facture-orphan-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; align-items: center; }
.facture-orphan-file { font-weight: 600; }
.facture-orphan-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 0.9rem; margin-top: 0.6rem; }
@media (max-width: 900px) { .facture-orphan-actions { grid-template-columns: 1fr; } }
.facture-attach-session { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.facture-attach-session .upload-label, .facture-attach-po .upload-label { width: 100%; }
.facture-attach-session select { flex: 1 1 14rem; min-width: 0; padding: 0.4rem; }
.facture-po-results { margin-top: 0.4rem; }
.facture-missing { border: 1px dashed #fbbf24; border-radius: 10px; background: #fffbeb; color: #92400e; }
.facture-missing form { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; align-items: center; margin: 0.5rem 0; }
.facture-missing select { max-width: 100%; padding: 0.35rem; }
.facture-detach-form { margin-top: 0.35rem; }
html[data-theme="dark"] .facture-assign-card .facture-orphan { background: #2a2418; border-color: #5c4a28; }
html[data-theme="dark"] .facture-missing { background: #2a2418; border-color: #5c4a28; color: #f5e6c8; }

/* v0.9.3 — Composant progression (barre fine + modal jobs), clair / sombre */
.rf-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000;
  background: rgba(37, 99, 235, 0.15); overflow: hidden; pointer-events: none;
}
.rf-topbar[hidden], .rf-topbar-label[hidden] { display: none !important; }
.rf-topbar-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.3s ease; }
.rf-topbar.rf-indeterminate .rf-topbar-fill,
.rf-progress.rf-indeterminate .rf-progress-fill {
  width: 35% !important; animation: rf-indet 1.2s ease-in-out infinite;
}
@keyframes rf-indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.rf-topbar-label {
  position: fixed; top: 8px; right: 12px; z-index: 2001; pointer-events: none;
  font-size: 0.78rem; padding: 0.2rem 0.55rem; border-radius: 999px;
  background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
html.rf-busy, html.rf-busy body { cursor: progress; }
.rf-btn-busy { opacity: 0.8; cursor: progress !important; }
.rf-spin {
  display: inline-block; width: 0.8em; height: 0.8em; margin-right: 0.4em; vertical-align: -0.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: rf-rot 0.7s linear infinite;
}
@keyframes rf-rot { to { transform: rotate(360deg); } }
.rf-job-modal { z-index: 1500; }
.rf-job-dialog { max-width: 560px; width: 100%; }
.rf-job-step { font-weight: 600; margin-bottom: 0.25rem; min-height: 1.3em; }
.rf-job-file { min-height: 1.2em; margin-bottom: 0.6rem; word-break: break-all; }
.rf-progress {
  height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--border); border: 1px solid var(--border);
}
.rf-progress-fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #60a5fa); transition: width 0.4s ease;
}
.rf-job-meta { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.35rem; }
.rf-job-pct { font-variant-numeric: tabular-nums; font-weight: 600; }
.rf-job-failed .rf-progress-fill { background: #dc2626; }
.rf-device-progress { margin: 0.5rem 0 0.25rem; }
html[data-theme="dark"] .rf-topbar { background: rgba(59, 130, 246, 0.2); }
html[data-theme="dark"] .rf-progress { background: #1f2937; border-color: var(--border); }

/* v0.9.5 — facture utilisée comme BL (fournisseur sans BL) */
.pill-info { background: #eff6ff; color: #1d4ed8; }
html[data-theme="dark"] .pill-info { background: #1e3a8a; color: #dbeafe; }
.facture-bl-badge { margin: 0.25rem 0 0.4rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.import-summary-note { flex-basis: 100%; margin-top: 0.15rem; }

/* v0.9.7 — liste des mails : Document / Commande Odoo / État stock */
.mail-select-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.mail-analyse-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.mail-hide-stock { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.mail-analyse-progress { display: flex; align-items: center; gap: 0.5rem; min-width: 260px; }
.mail-analyse-progress .rf-progress { width: 140px; flex: 0 0 140px; }
.mail-table td.mail-an { vertical-align: top; min-width: 8rem; }
.mail-table .ma-line { line-height: 1.35; padding: 0.1rem 0; }
.mail-table .ma-line + .ma-line { border-top: 1px dashed var(--border); margin-top: 0.2rem; padding-top: 0.25rem; }
.ma-sup { font-weight: 600; }
.ma-sub { font-size: 0.78rem; margin-top: 0.1rem; }
.ma-via { font-size: 0.75rem; }
.ma-hist { margin-top: 0.3rem; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.ma-badge { display: inline-block; padding: 0.08rem 0.45rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; background: #f1f5f9; color: #475569; }
.ma-type-bl { background: #eef4ff; color: #1d4ed8; }
.ma-type-fac { background: #f5f3ff; color: #6d28d9; }
.ma-type-facbl { background: #fdf4ff; color: #a21caf; }
.ma-st-analyse { background: #f1f5f9; color: #64748b; animation: ma-pulse 1.4s ease-in-out infinite; }
.ma-st-a_receptionner { background: #fff7ed; color: #c2410c; }
.ma-st-partiel { background: #eef4ff; color: #1d4ed8; }
.ma-st-en_stock { background: #ecfdf5; color: #047857; }
.ma-st-introuvable, .ma-st-erreur { background: #fef2f2; color: #b91c1c; }
.ma-st-annulee, .ma-st-non_confirmee, .ma-st-sans_objet { background: #f1f5f9; color: #475569; }
.ma-st-licence { background: #e0f2fe; color: #075985; border: 1px dashed #7dd3fc; }
.ma-flag { background: #f0f9ff; color: #0369a1; font-weight: 500; }
.ma-flag-sp { background: #ecfeff; color: #0e7490; font-weight: 500; }
@keyframes ma-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
html[data-theme="dark"] .ma-badge { background: #1f2937; color: #cbd5e1; }
html[data-theme="dark"] .ma-type-bl { background: #1e3a8a; color: #dbeafe; }
html[data-theme="dark"] .ma-type-fac { background: #3b0764; color: #ede9fe; }
html[data-theme="dark"] .ma-type-facbl { background: #4a044e; color: #fae8ff; }
html[data-theme="dark"] .ma-st-analyse { background: #1f2937; color: #94a3b8; }
html[data-theme="dark"] .ma-st-a_receptionner { background: #431407; color: #fed7aa; }
html[data-theme="dark"] .ma-st-partiel { background: #1e3a8a; color: #dbeafe; }
html[data-theme="dark"] .ma-st-en_stock { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .ma-st-introuvable, html[data-theme="dark"] .ma-st-erreur { background: #450a0a; color: #fecaca; }
html[data-theme="dark"] .ma-st-licence { background: #0c4a6e; color: #bae6fd; border-color: #0369a1; }
html[data-theme="dark"] .ma-flag { background: #0c4a6e; color: #e0f2fe; }
html[data-theme="dark"] .ma-flag-sp { background: #164e63; color: #cffafe; }

/* v0.9.9 — besoins clients / étiquettes d'affectation */
.alloc-summary { margin: 0.4rem 0 0.6rem; padding: 0.45rem 0.7rem; border-radius: 8px; background: #fdf4ff; color: #701a75; border: 1px solid #f5d0fe; }
.alloc-badges { margin-top: 0.15rem; }
.alloc-badge { background: #fae8ff; color: #86198f; font-weight: 600; white-space: normal; border-radius: 6px; line-height: 1.25; }
html[data-theme="dark"] .alloc-summary { background: #3b0764; color: #f5d0fe; border-color: #6b21a8; }
html[data-theme="dark"] .alloc-badge { background: #4a044e; color: #fae8ff; }
.result-assign { text-align: left; margin-top: 0.5rem; padding: 0.4rem 0.7rem; border-radius: 8px; background: #fdf4ff; color: #701a75; }
.result-assign ul { margin: 0.2rem 0 0.3rem 1.1rem; padding: 0; }
.result-assign p { margin: 0.2rem 0; }
.result-assign-ko { color: #b91c1c; }
html[data-theme="dark"] .result-assign { background: #3b0764; color: #f5d0fe; }
html[data-theme="dark"] .result-assign-ko { color: #fecaca; }

/* v0.11.0 — contrôle OCR par ligne (Mac Studio) */
.ocr-ctl{font-size:.82em;margin-top:2px}
.ocr-ctl-auto{color:#1a7f37}
.ocr-ctl-verif{color:#b35900;font-weight:600}

/* v0.11.1 — lot 1 : types de document (BL / Facture) + colonne « Sur la facture » */
.doc-kinds .ma-badge { margin-right: 0.25rem; }
.ma-line .ma-badge + .ma-badge { margin-left: 0.2rem; }
td.qte-diff { color: #b45309; font-weight: 600; }
td.qte-diff::after { content: " ≠"; font-size: 0.8em; }

/* v0.11.2 — lot 2 : barre d'action fixe, menus ⋯, enregistrement auto */
.action-bar { position: sticky; bottom: 0; z-index: 40; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin: 1rem -0.5rem 0; padding: 0.75rem 1rem; background: var(--card, #fff); border-top: 1px solid var(--border, #e3e7ee);
  box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.08); border-radius: 12px 12px 0 0; }
.action-bar-left { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.action-bar-right { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.btn-lg { min-height: 48px; padding: 0 1.1rem; font-size: 1rem; }
.btn-xl { min-height: 52px; padding: 0 1.6rem; font-size: 1.1rem; font-weight: 700; }
.btn-danger-outline { color: #b42318; border-color: #f3b4b4; }
.reels-status { font-size: 0.92rem; color: var(--muted, #6b7385); }
.reels-status.reels-ok { color: #1f7a4d; }
.reels-status.reels-pending, .reels-status.reels-saving { color: #a35b00; }
.reels-status.reels-error { color: #b42318; font-weight: 600; }
.more-menu { position: relative; display: inline-block; }
.more-menu > summary { list-style: none; cursor: pointer; user-select: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu-list { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 260px; padding: 0.35rem;
  background: var(--card, #fff); border: 1px solid var(--border, #e3e7ee); border-radius: 12px; box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16); }
.more-menu-right, .mail-status-pills .more-menu-list { left: auto; right: 0; }
.more-menu-list form { margin: 0; }
.more-item { display: block; width: 100%; text-align: left; padding: 0.7rem 0.85rem; min-height: 44px; border: 0; background: none;
  border-radius: 8px; font: inherit; color: inherit; text-decoration: none; cursor: pointer; }
.more-item:hover, .more-item:focus-visible { background: rgba(37, 99, 235, 0.08); }
.more-item:disabled { opacity: 0.45; cursor: not-allowed; }
.more-item-danger { color: #b42318; }
.more-item-muted { color: var(--muted, #6b7385); }
.header-more { justify-content: flex-end; }
.inline-form { display: inline; }

/* v0.11.3 — n° de série en doublon dans la fenêtre de saisie */
.sn-input.sn-dup { border-color: var(--danger, #dc2626); background: #fef2f2; }
