/* =====================================================================
   Invoice module — invoice.css
   Préfixe : inv-*
   ===================================================================== */

/* ── Layout page ──────────────────────────────────────────────────────── */
.invoices-view {
  padding: var(--ds-space-6);
  font-family: var(--ds-font-sans);
  color: var(--ds-text);
}

.inv-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--ds-space-6);
  gap: var(--ds-space-4);
}

.inv-page-title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ds-text);
}

.inv-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--ds-space-6) 0 var(--ds-space-3);
  gap: var(--ds-space-4);
}

.inv-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--ds-text);
}

.inv-back {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ds-text-secondary);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  padding: var(--ds-space-1) 0;
  margin-bottom: var(--ds-space-4);
  transition: color var(--ds-duration-fast) var(--ds-ease-premium);
}
.inv-back:hover { color: var(--ds-text); }

.inv-loading {
  color: var(--ds-text-muted);
  font-size: var(--ds-text-sm);
  padding: var(--ds-space-8) 0;
  text-align: center;
}

.inv-empty {
  color: var(--ds-text-muted);
  font-size: var(--ds-text-sm);
  text-align: center;
  padding: var(--ds-space-8) var(--ds-space-4);
  background: var(--ds-bg-elevated);
  border-radius: var(--ds-radius-lg);
  border: 1px solid var(--ds-border);
}

/* ── Boutons ──────────────────────────────────────────────────────────── */
.inv-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  border: none;
  border-radius: var(--ds-radius-md);
  cursor: pointer;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  font-weight: 600;
  padding: 10px var(--ds-space-5);
  transition: background var(--ds-duration-fast) var(--ds-ease-premium),
              box-shadow var(--ds-duration-fast) var(--ds-ease-premium),
              opacity var(--ds-duration-fast);
  white-space: nowrap;
}
.inv-btn--primary {
  background: var(--ds-action);
  color: #fff;
}
.inv-btn--primary:hover:not(:disabled) {
  background: var(--ds-action-hover);
  box-shadow: var(--ds-shadow-sm);
}
.inv-btn--ghost {
  background: transparent;
  color: var(--ds-text-secondary);
  border: 1px solid var(--ds-border-strong);
}
.inv-btn--ghost:hover:not(:disabled) {
  background: var(--ds-bg-app);
  color: var(--ds-text);
}
.inv-btn--hero {
  background: #ffffff;
  color: #073CBF;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: box-shadow 0.15s, transform 0.1s;
}
.inv-btn--hero:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}
.inv-btn--sm {
  font-size: var(--ds-text-xs);
  padding: 6px var(--ds-space-3);
  border-radius: var(--ds-radius-sm);
}
.inv-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.inv-save-btn,
.inv-validate-btn {
  display: block;
  width: 100%;
  margin-top: var(--ds-space-6);
  padding: 14px;
  font-size: var(--ds-text-md);
  border-radius: var(--ds-radius-lg);
  text-align: center;
  justify-content: center;
}

/* ── En-tête dégradé bleu ─────────────────────────────────────────────── */
.inv-hero {
  background: linear-gradient(135deg, #073CBF 0%, #051040 100%);
  border-radius: 16px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(5, 16, 64, 0.25);
}

.inv-hero-body { flex: 1; min-width: 0; }

.inv-hero-overline {
  margin: 0 0 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
}

.inv-hero-title {
  margin: 0 0 5px;
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #ffffff;
  line-height: 1;
}

.inv-hero-subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
  line-height: 1.4;
  max-width: 420px;
}

.inv-hero-actions { flex-shrink: 0; }

/* ── Stats KPI ─────────────────────────────────────────────────────────── */
.inv-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ── Badges statut ────────────────────────────────────────────────────── */
.inv-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--ds-radius-pill);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.inv-badge--draft     { background: rgba(217, 119, 6, 0.12);  color: #92400e; }
.inv-badge--validated { background: rgba(5, 150, 105, 0.12);  color: #065f46; }

/* ── Liste des factures ───────────────────────────────────────────────── */
.inv-list {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
}

.inv-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: center;
  gap: var(--ds-space-4);
  background: #ffffff;
  border: 1px solid #e8edf4;
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.inv-card:hover {
  border-color: #d1dbe8;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 8px 20px rgba(0, 0, 0, 0.06);
}

.inv-card-supplier {
  font-size: var(--ds-text-sm);
  font-weight: 700;
  color: #0f172a;
}
.inv-card-num {
  font-size: var(--ds-text-sm);
  color: #64748b;
  font-feature-settings: "tnum";
}
.inv-card-date {
  font-size: var(--ds-text-sm);
  color: #94a3b8;
}

/* ── Formulaire nouvelle facture ──────────────────────────────────────── */
.inv-form-card {
  background: var(--ds-bg-elevated);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-xl);
  padding: var(--ds-space-5);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--ds-space-4);
  margin-bottom: var(--ds-space-5);
}

.inv-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-label {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  color: var(--ds-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-input,
.inv-select {
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-md);
  background: var(--ds-bg-app);
  color: var(--ds-text);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--ds-duration-fast), box-shadow var(--ds-duration-fast);
  width: 100%;
  box-sizing: border-box;
}
.inv-input:focus,
.inv-select:focus {
  border-color: var(--ds-action);
  box-shadow: var(--ds-focus-ring);
}
.inv-inp--error {
  border-color: var(--ds-danger) !important;
  box-shadow: 0 0 0 3px var(--ds-danger-soft) !important;
}

/* ── Tableau de saisie des lignes ─────────────────────────────────────── */
.inv-lines-col-hdr {
  display: grid;
  grid-template-columns: 100px 1fr 60px 70px 90px 90px 32px;
  gap: var(--ds-space-2);
  padding: 0 var(--ds-space-3) var(--ds-space-1);
}
.inv-col {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  color: var(--ds-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-lines-body {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
}

.inv-line-row {
  display: grid;
  grid-template-columns: 100px 1fr 60px 70px 90px 90px 32px;
  gap: var(--ds-space-2);
  align-items: center;
}

.inv-line-inp {
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-bg-elevated);
  color: var(--ds-text);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  padding: 7px 10px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--ds-duration-fast), box-shadow var(--ds-duration-fast);
}
.inv-line-inp:focus {
  border-color: var(--ds-action);
  box-shadow: var(--ds-focus-ring);
}
.inv-line-inp--qty,
.inv-line-inp--price { text-align: right; }

.inv-line-amount {
  font-size: var(--ds-text-sm);
  font-weight: 600;
  color: var(--ds-text-secondary);
  font-feature-settings: "tnum";
  text-align: right;
  white-space: nowrap;
}

.inv-line-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ds-text-muted);
  font-size: 1.125rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--ds-radius-sm);
  transition: color var(--ds-duration-fast), background var(--ds-duration-fast);
}
.inv-line-del:hover { color: var(--ds-danger); background: var(--ds-danger-soft); }

/* ── En-tête détail facture ───────────────────────────────────────────── */
.inv-detail-hdr {
  background: var(--ds-bg-elevated);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-xl);
  padding: var(--ds-space-5);
  margin-bottom: var(--ds-space-5);
}

.inv-detail-meta {
  display: flex;
  align-items: center;
  gap: var(--ds-space-4);
  flex-wrap: wrap;
}

.inv-detail-supplier {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ds-text);
}
.inv-detail-num {
  font-size: var(--ds-text-sm);
  color: var(--ds-text-secondary);
  font-feature-settings: "tnum";
}
.inv-detail-date {
  font-size: var(--ds-text-sm);
  color: var(--ds-text-muted);
}

/* ── Lignes de correction ─────────────────────────────────────────────── */
.inv-correction {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
  margin-bottom: var(--ds-space-5);
}

.inv-lcard {
  background: var(--ds-bg-elevated);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
  transition: box-shadow var(--ds-duration-fast) var(--ds-ease-premium);
}
.inv-lcard--to-link  { border-left: 3px solid var(--ds-danger); }
.inv-lcard--mismatch { border-left: 3px solid var(--ds-warning); }
.inv-lcard--matched  { border-left: 3px solid var(--ds-success); }
.inv-lcard--ignored  { border-left: 3px solid var(--ds-border-strong); opacity: 0.6; }

.inv-lcard-main {
  display: grid;
  grid-template-columns: 100px 1fr 90px 100px auto;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
}

.inv-lcard-ref {
  font-size: var(--ds-text-xs);
  font-family: "Geist", ui-monospace, monospace;
  color: var(--ds-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-lcard-label {
  font-size: var(--ds-text-sm);
  font-weight: 500;
  color: var(--ds-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-lcard-qty,
.inv-lcard-price {
  font-size: var(--ds-text-xs);
  color: var(--ds-text-secondary);
  font-feature-settings: "tnum";
  white-space: nowrap;
}

/* Badges lignes */
.inv-lbadge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--ds-radius-pill);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.inv-lbadge--matched  { background: var(--ds-success-soft); color: var(--ds-success); }
.inv-lbadge--to-link  { background: var(--ds-danger-soft);  color: var(--ds-danger);  }
.inv-lbadge--mismatch { background: var(--ds-warning-soft); color: var(--ds-warning); }
.inv-lbadge--ignored  { background: var(--ds-bg-app);       color: var(--ds-text-muted); }

/* Variation de prix */
.inv-lcard-var {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  padding: 4px var(--ds-space-4);
  border-top: 1px solid var(--ds-border);
}
.inv-lcard-var--up   { background: var(--ds-danger-soft);  color: var(--ds-danger);  }
.inv-lcard-var--down { background: var(--ds-success-soft); color: var(--ds-success); }

/* Zone d'action */
.inv-lcard-action {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-top: 1px solid var(--ds-border);
  background: var(--ds-bg-app);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
}

/* Recherche produit (to_link) */
.inv-search-inp {
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-md);
  background: var(--ds-bg-elevated);
  color: var(--ds-text);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  padding: 8px 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  transition: border-color var(--ds-duration-fast), box-shadow var(--ds-duration-fast);
}
.inv-search-inp:focus {
  border-color: var(--ds-action);
  box-shadow: var(--ds-focus-ring);
}

.inv-search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inv-result-item {
  background: var(--ds-bg-elevated);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-sm);
  color: var(--ds-text);
  cursor: pointer;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  padding: 7px 12px;
  text-align: left;
  transition: background var(--ds-duration-fast), border-color var(--ds-duration-fast);
  width: 100%;
}
.inv-result-item:hover {
  background: var(--ds-action-soft);
  border-color: var(--ds-action);
}

/* Confirmation de conditionnement (unit_mismatch) */
.inv-cond-prompt {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  flex-wrap: wrap;
  font-size: var(--ds-text-sm);
  color: var(--ds-text-secondary);
}

.inv-cond-inp {
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-bg-elevated);
  color: var(--ds-text);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  padding: 6px 10px;
  outline: none;
  width: 90px;
  text-align: right;
  font-feature-settings: "tnum";
  transition: border-color var(--ds-duration-fast), box-shadow var(--ds-duration-fast);
}
.inv-cond-inp:focus {
  border-color: var(--ds-action);
  box-shadow: var(--ds-focus-ring);
}

.inv-cond-unit {
  font-size: var(--ds-text-xs);
  font-weight: 600;
  color: var(--ds-text-muted);
}

/* Onglets Lier / Créer (to_link) */
.inv-link-tabs {
  display: flex;
  border-bottom: 1px solid var(--ds-border);
  margin-bottom: var(--ds-space-2);
}
.inv-link-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--ds-text-muted);
  cursor: pointer;
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: var(--ds-space-2) var(--ds-space-3);
  transition: color var(--ds-duration-fast), border-color var(--ds-duration-fast);
  white-space: nowrap;
}
.inv-link-tab:hover:not(.inv-link-tab--active) { color: var(--ds-text); }
.inv-link-tab--active { color: var(--ds-action); border-bottom-color: var(--ds-action); }

/* Formulaire de création produit */
.inv-create-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ds-space-3);
}
.inv-cond-section {
  display: flex;
  align-items: center;
  gap: var(--ds-space-2);
  flex-wrap: wrap;
}

/* ── Avertissement sanity (prix hors plage) ───────────────────────────── */
.inv-sanity-warning {
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-3) var(--ds-space-4);
  margin-top: var(--ds-space-3);
}
.inv-sanity-msg {
  margin: 0 0 var(--ds-space-3);
  font-size: var(--ds-text-sm);
  color: #92400e;
  line-height: 1.5;
}
.inv-sanity-actions {
  display: flex;
  gap: var(--ds-space-2);
  flex-wrap: wrap;
}

/* ── Vues PDF (extraction + parsing) ─────────────────────────────────── */
.inv-pdf-status {
  color: var(--ds-text-muted);
  font-size: var(--ds-text-sm);
  margin: var(--ds-space-4) 0;
}
.inv-pdf-error { color: var(--ds-danger); }
.inv-pdf-info {
  font-size: var(--ds-text-sm);
  color: var(--ds-text-muted);
  margin: 0 0 var(--ds-space-3);
}
.inv-pdf-raw {
  background: var(--ds-surface-raised, #f8fafc);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-4);
  font-family: var(--ds-font-mono, monospace);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
  color: var(--ds-text);
}
.inv-pdf-raw--sm { font-size: 11px; max-height: 40vh; }

/* Méta en-tête parsing */
.inv-pdf-meta {
  display: flex;
  gap: var(--ds-space-6);
  flex-wrap: wrap;
  font-size: var(--ds-text-sm);
  color: var(--ds-text-muted);
  margin-bottom: var(--ds-space-4);
}
.inv-pdf-meta strong { color: var(--ds-text); }

/* Bannière total */
.inv-pdf-banner {
  border-radius: var(--ds-radius-md);
  padding: var(--ds-space-3) var(--ds-space-4);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  margin-bottom: var(--ds-space-5);
}
.inv-pdf-banner--ok   { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.inv-pdf-banner--err  { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.inv-pdf-banner--warn { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }

/* Table lignes parsées */
.inv-pdf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ds-text-sm);
  margin-bottom: var(--ds-space-6);
}
.inv-pdf-table th {
  text-align: left;
  padding: var(--ds-space-2) var(--ds-space-3);
  border-bottom: 2px solid var(--ds-border);
  font-weight: 600;
  color: var(--ds-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.inv-pdf-table td {
  padding: var(--ds-space-2) var(--ds-space-3);
  border-bottom: 1px solid var(--ds-border);
  vertical-align: middle;
}
.inv-pdf-table tr:hover td { background: var(--ds-surface-raised, #f8fafc); }
.inv-pdf-num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badge type stockage */
.inv-pdf-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.inv-pdf-type--s { background: #dbeafe; color: #1e40af; } /* Surgelé */
.inv-pdf-type--a { background: #fef9c3; color: #854d0e; } /* Ambiant */
.inv-pdf-type--f { background: #dcfce7; color: #166534; } /* Frais */

/* Bouton import lignes PDF */
.inv-pdf-import-btn { display: block; margin: var(--ds-space-5) 0 var(--ds-space-4); }

/* Repli texte brut */
.inv-pdf-details { margin-top: var(--ds-space-4); }
.inv-pdf-summary {
  cursor: pointer;
  font-size: var(--ds-text-sm);
  color: var(--ds-text-muted);
  padding: var(--ds-space-2) 0;
  user-select: none;
}
.inv-pdf-summary:hover { color: var(--ds-text); }
.inv-pdf-details[open] .inv-pdf-summary { margin-bottom: var(--ds-space-3); }

/* ── Toast notifications ──────────────────────────────────────────────── */
.inv-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 12px 20px;
  border-radius: var(--ds-radius-lg);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  font-weight: 500;
  box-shadow: var(--ds-shadow-md);
  max-width: 480px;
  text-align: center;
  transition: opacity var(--ds-duration-base) var(--ds-ease-premium);
  opacity: 1;
}
.inv-toast--out { opacity: 0; }
.inv-toast--success { background: var(--ds-success); color: #fff; }
.inv-toast--error   { background: var(--ds-danger);  color: #fff; }
.inv-toast--info    { background: var(--ds-text);    color: #fff; }

/* ── Mode sombre ──────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  .inv-form-card,
  .inv-detail-hdr,
  .inv-lcard {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.08);
  }
  .inv-lcard-action      { background: #0f172a; }
  .inv-sanity-warning    { background: #1c1a0e; border-color: #b45309; }
  .inv-sanity-msg        { color: #fcd34d; }
  .inv-pdf-raw           { background: #0f172a; }
  .inv-pdf-banner--ok    { background: #052e16; color: #86efac; border-color: #166534; }
  .inv-pdf-banner--err   { background: #2d0a0a; color: #fca5a5; border-color: #7f1d1d; }
  .inv-pdf-banner--warn  { background: #1c1a0e; color: #fcd34d; border-color: #b45309; }
  .inv-pdf-type--s       { background: #1e3a5f; color: #93c5fd; }
  .inv-pdf-type--a       { background: #2d2500; color: #fcd34d; }
  .inv-pdf-type--f       { background: #052e16; color: #86efac; }
  .inv-input,
  .inv-select,
  .inv-search-inp,
  .inv-line-inp,
  .inv-cond-inp,
  .inv-result-item { background: #1e293b; border-color: rgba(255, 255, 255, 0.10); }
  /* inv-card intentionnellement blanc en dark mode (carte-style Mercuriale) */
}
:root[data-theme="dark"] .inv-form-card,
:root[data-theme="dark"] .inv-detail-hdr,
:root[data-theme="dark"] .inv-lcard {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}
:root[data-theme="dark"] .inv-lcard-action  { background: #0f172a; }
:root[data-theme="dark"] .inv-sanity-warning { background: #1c1a0e; border-color: #b45309; }
:root[data-theme="dark"] .inv-sanity-msg     { color: #fcd34d; }
:root[data-theme="dark"] .inv-pdf-raw        { background: #0f172a; }
:root[data-theme="dark"] .inv-pdf-banner--ok   { background: #052e16; color: #86efac; border-color: #166534; }
:root[data-theme="dark"] .inv-pdf-banner--err  { background: #2d0a0a; color: #fca5a5; border-color: #7f1d1d; }
:root[data-theme="dark"] .inv-pdf-banner--warn { background: #1c1a0e; color: #fcd34d; border-color: #b45309; }
:root[data-theme="dark"] .inv-pdf-type--s   { background: #1e3a5f; color: #93c5fd; }
:root[data-theme="dark"] .inv-pdf-type--a   { background: #2d2500; color: #fcd34d; }
:root[data-theme="dark"] .inv-pdf-type--f   { background: #052e16; color: #86efac; }
:root[data-theme="dark"] .inv-input,
:root[data-theme="dark"] .inv-select,
:root[data-theme="dark"] .inv-search-inp,
:root[data-theme="dark"] .inv-line-inp,
:root[data-theme="dark"] .inv-cond-inp,
:root[data-theme="dark"] .inv-result-item { background: #1e293b; border-color: rgba(255, 255, 255, 0.10); }
/* :root[data-theme="dark"] .inv-card → intentionnellement blanc (carte-style Mercuriale) */

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .invoices-view { padding: var(--ds-space-4); }
  .inv-form-card { grid-template-columns: 1fr; }
  .inv-card { grid-template-columns: 1fr auto; row-gap: var(--ds-space-1); }
  .inv-card-num,
  .inv-card-date { font-size: 11px; }
  .inv-lcard-main { grid-template-columns: 80px 1fr auto; }
  .inv-lcard-qty,
  .inv-lcard-price { display: none; }
  .inv-lines-col-hdr { display: none; }
  .inv-line-row { grid-template-columns: 80px 1fr 50px 60px 80px 70px 28px; }
}

/* ── Compte rendu post-validation ──────────────────────────────────────────── */
.cr-hero {
  background: linear-gradient(135deg, #073CBF, #051040);
  border-radius: 24px;
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: 0 20px 50px rgba(7, 60, 191, .28);
}
.cr-hero .top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.cr-hero .top .ic {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.cr-hero .top .t b  { font-size: 1.2rem; font-weight: 800; display: block; }
.cr-hero .top .t small { font-size: .82rem; color: rgba(255, 255, 255, .7); }
.cr-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.cr-stat {
  background: rgba(255, 255, 255, .1);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}
.cr-stat .v {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -.02em;
}
.cr-stat .k {
  font-size: .72rem;
  font-weight: 700;
  color: rgba(255, 255, 255, .7);
  margin-top: 2px;
}
/* KPI colorés sur fond bleu nuit — contraste ≥ 4.5:1 vérifié */
.cr-stat--hausse .v  { color: #fca5a5; } /* rouge pâle */
.cr-stat--baisse .v  { color: #6ee7b7; } /* vert menthe */
.cr-stat--surcout .v { color: #fca5a5; }
.cr-stat--eco .v     { color: #6ee7b7; }
.cr-section {
  background: #fff;
  border-radius: 16px;
  border: 1.5px solid #e8ecf3;
  padding: 18px 20px;
  margin-bottom: 14px;
}
.cr-section h4 {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 12px;
}
.cr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #e8ecf3;
}
.cr-item:last-child { border-bottom: 0; }
.cr-item .nm       { font-size: .92rem; font-weight: 700; }
.cr-item .nm small { display: block; font-size: .74rem; color: #94a3b8; font-weight: 600; }
.cr-item .impact   { font-size: .85rem; font-weight: 800; }
.cr-item .impact.bad  { color: #dc2626; }
.cr-item .impact.good { color: #0e9f6e; }
.cr-empty      { font-size: .88rem; color: #94a3b8; padding: 8px 0; }
.cr-empty--warn { color: #d97706; }
.price-move { display: flex; align-items: center; gap: 12px; }
.pm-vals {
  font-size: .92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 7px;
}
.pm-vals .old { color: #94a3b8; text-decoration: line-through; font-weight: 600; }
.pm-vals .arr { color: #94a3b8; }
.pm-vals .new.bad  { color: #dc2626; }
.pm-vals .new.good { color: #0e9f6e; }
.chip-var {
  font-size: .76rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.chip-var.up   { background: #fee2e2; color: #dc2626; }
.chip-var.down { background: #d1fae5; color: #059669; }
.cr-cta-wrap {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.cr-cta {
  flex: 1;
  padding: 14px 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, #073CBF, #051040);
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
  border: 0;
  cursor: pointer;
  transition: opacity .15s;
}
.cr-cta:hover { opacity: .88; }

/* ── Section prix négociés vérifiés ────────────────────────────────────────── */
.cr-verif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e8ecf3;
}
.cr-verif-item:last-of-type { border-bottom: 0; }
.cr-verif-icon {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 900;
}
/* Icône + couleur + libellé texte — règle daltonisme */
.cr-verif-item--ok  .cr-verif-icon { background: #d1fae5; color: #059669; }
.cr-verif-item--nok .cr-verif-icon { background: #fef3c7; color: #b45309; }
.cr-verif-body { flex: 1; min-width: 0; }
.cr-verif-body b { display: block; font-size: .9rem; font-weight: 700; }
.cr-verif-status {
  display: block;
  font-size: .77rem;
  font-weight: 800;
  margin-top: 2px;
}
.cr-verif-item--ok  .cr-verif-status { color: #059669; }
.cr-verif-item--nok .cr-verif-status { color: #b45309; }
.cr-verif-prices {
  display: block;
  font-size: .78rem;
  color: #64748b;
  margin-top: 3px;
}
.cr-relance-btn {
  margin-top: 14px;
  width: 100%;
  padding: 12px 20px;
  border-radius: 12px;
  background: #fff;
  border: 2px solid #b45309;
  color: #b45309;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cr-relance-btn:hover { background: #b45309; color: #fff; }

/* ── Tableau "Voir la facture" dans le compte rendu ────────────────────────── */
.cr-lines-details {
  margin: 0 0 16px;
}
.cr-lines-summary {
  cursor: pointer;
  list-style: none;
  font-size: .85rem;
  font-weight: 600;
  color: #64748b;
  padding: 6px 2px;
  user-select: none;
}
.cr-lines-summary::-webkit-details-marker { display: none; }
.cr-lines-summary::before { content: "\25b6  "; font-size: .7em; opacity: .6; }
details[open] .cr-lines-summary::before { content: "\25bc  "; }
.cr-lines-details .inv-pdf-table { margin-top: 8px; margin-bottom: 0; }
.cr-lines-total td {
  border-top: 2px solid var(--ds-border, #e2e8f3);
  font-weight: 700;
  border-bottom: 0;
}

/* ── Assistant guidé (wizard) — thème clair fixe ───────────────────────────── */
.inv-wiz-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 18px;
  padding: 16px 20px;
  margin-bottom: 20px;
  border: 1.5px solid #e2e8f3;
  box-shadow: 0 2px 12px rgba(5, 16, 64, .06);
}
.inv-wiz-ic  { font-size: 1.5rem; flex-shrink: 0; }
.inv-wiz-txt { font-size: .88rem; color: #64748b; line-height: 1.5; }
.inv-wiz-txt strong { display: block; font-size: 1rem; color: #0f172a; font-weight: 800; margin-bottom: 2px; }
.inv-wiz-txt b { color: #073CBF; }

/* Barre de progression (même largeur que la carte) */
.prog            { margin-bottom: 20px; }
.prog-top        { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.prog-top .sup   { font-size: .82rem; font-weight: 700; color: #64748b; }
.prog-top .count { font-size: .82rem; font-weight: 800; color: #073CBF; }
.prog-bar        { height: 8px; border-radius: 999px; background: #dde5f2; overflow: hidden; }
.prog-fill       { height: 100%; background: linear-gradient(135deg, #073CBF, #051040); border-radius: 999px; transition: width .4s; }

/* Carte question — largeur 760 px, alignée avec la barre */
.qcard-wrap { max-width: 760px; margin: 0 auto; }
.qcard { background: #fff; border-radius: 24px; box-shadow: 0 12px 40px rgba(5,16,64,.10); overflow: hidden; }
.qhead { padding: 24px 30px 0; }
.qtag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.qtag.price { background: #fdeaea; color: #dc2626; }
.qtag.unit  { background: #fdf0dc; color: #c2740a; }
.qtag.new   { background: rgba(7,60,191,.1); color: #073CBF; }
.qproduct   { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; color: #0f172a; }
.qproduct small { display: block; font-size: .8rem; color: #94a3b8; font-weight: 600; margin-top: 3px; }
.qbody    { padding: 22px 30px 28px; }
.question { font-size: 1.05rem; font-weight: 600; line-height: 1.5; margin-bottom: 18px; color: #0f172a; }
.question b { color: #073CBF; font-weight: 800; }
.hint {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: #f4f7fc;
  border-radius: 16px;
  padding: 13px 15px;
  margin-bottom: 20px;
  font-size: .86rem;
  color: #64748b;
  line-height: 1.4;
}
.hint .ic { flex: none; font-size: 1rem; margin-top: 1px; }
.hint b   { color: #0f172a; font-weight: 700; }

/* Pied de carte */
.qfoot {
  display: flex;
  gap: 10px;
  padding: 0 30px 26px;
  flex-wrap: wrap;
}

/* Sécurité carte sanity : Corriger (primary, pleine largeur) au-dessus */
.qfoot--sanity .btn.primary    { order: -1; flex: 1 0 100%; }
.qfoot--sanity .btn--warn-confirm {
  flex: 1;
  font-size: .86rem;
  background: #fef3c7;
  color: #92400e;
  border: 1.5px solid #fcd34d;
}
.qfoot--sanity .btn--warn-confirm:hover { background: #fde68a; }
.qfoot--sanity .btn--skip { flex: 0 0 auto; color: #94a3b8; }

/* Boutons */
.btn { border: 0; border-radius: 16px; padding: 15px; font: inherit; font-weight: 800; font-size: .98rem; cursor: pointer; }
.btn.primary { flex: 1; background: linear-gradient(135deg,#073CBF,#051040); color: #fff; box-shadow: 0 6px 18px rgba(7,60,191,.28); }
.btn.primary:hover    { opacity: .88; }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.ghost  { flex: 0 0 auto; background: #f4f7fc; color: #64748b; padding: 15px 22px; }
.btn.ghost:hover { background: #e8eef8; }

/* Champs de saisie clairs */
.wiz-input, .inv-cond-inp {
  background: #f4f7fc;
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 13px 15px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
}
.wiz-input:focus, .inv-cond-inp:focus {
  outline: 0;
  border-color: #073CBF;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(7,60,191,.08);
}

/* Saisie conditionnement inline */
.inv-cond-inline { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.cond-label { font-size: .9rem; font-weight: 600; color: #475569; white-space: nowrap; }
.cond-unit  { font-size: .9rem; color: #64748b; }

/* Dropdown recherche produit dans le wizard — force thème clair (override dark mode) */
.qcard-wrap .inv-search-inp {
  background: #f4f7fc;
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 13px 15px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  width: 100%;
  box-sizing: border-box;
}
.qcard-wrap .inv-search-inp:focus {
  outline: 0;
  border-color: #073CBF;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(7,60,191,.08);
}
.qcard-wrap .inv-search-results {
  background: #fff;
  border: 1.5px solid #e8ecf3;
  border-radius: 16px;
  overflow: hidden;
  margin-top: 8px;
  gap: 0;
}
.qcard-wrap .inv-result-item {
  padding: 13px 16px;
  font-size: .92rem;
  font-weight: 600;
  color: #0f172a;
  background: #fff;
  border: 0;
  border-bottom: 1px solid #e8ecf3;
  border-radius: 0;
  cursor: pointer;
  transition: background .12s;
  width: 100%;
  text-align: left;
}
.qcard-wrap .inv-result-item:last-child { border-bottom: 0; }
.qcard-wrap .inv-result-item:hover {
  background: rgba(7,60,191,.08);
  color: #073CBF;
  border-color: #e8ecf3;
}

/* Hint suggestion + calcul en direct */
.wiz-hint-ok {
  font-size: .8rem;
  font-weight: 700;
  color: #16a34a;
  margin-top: 6px;
  min-height: 18px;
  line-height: 1.4;
}
.wiz-calc {
  font-size: .85rem;
  color: #64748b;
  margin-top: 10px;
  min-height: 22px;
  line-height: 1.5;
}
.wiz-calc b {
  color: #073CBF;
  font-weight: 800;
}

/* ── Onglets Lier / Créer ────────────────────────────────────────────────── */
.wiz-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 30px;
  background: #f8fafc;
  border-top: 1px solid #e8ecf3;
  border-bottom: 1px solid #e8ecf3;
}
.wiz-tab {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid #e2e8f3;
  border-radius: 12px;
  background: #fff;
  color: #64748b;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.wiz-tab--active {
  background: #073CBF;
  color: #fff;
  border-color: #073CBF;
}

/* ── Formulaire de création produit ─────────────────────────────────────── */
.wiz-create-field { margin-bottom: 14px; }
.wiz-create-field .cond-label,
.wiz-create-col   .cond-label { display: block; margin-bottom: 6px; }
.wiz-create-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.wiz-create-inp { width: 100%; box-sizing: border-box; }
.wiz-select {
  width: 100%;
  background: #f4f7fc;
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 13px 15px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  appearance: none;
  box-sizing: border-box;
}
.wiz-select:focus {
  outline: 0;
  border-color: #073CBF;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(7,60,191,.08);
}
.wiz-info-hint { margin-top: 0; margin-bottom: 0; }
.wiz-create-btn { width: 100%; margin-top: 16px; }
.wiz-create-err { font-size: .83rem; color: #dc2626; margin-top: 8px; font-weight: 600; }

/* ── Dropdown catégorie ───────────────────────────────────────────────────── */
.wiz-cat-dropdown { position: relative; }
.wiz-cat-trigger {
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 15px;
  background: #f4f7fc;
  border: 1.5px solid transparent;
  border-radius: 16px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  box-sizing: border-box;
}
.wiz-cat-trigger:focus {
  outline: 0;
  border-color: #073CBF;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(7,60,191,.08);
}
.wiz-cat-arrow { opacity: .45; font-size: .8em; }
.wiz-cat-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1.5px solid #e2e8f3;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  z-index: 200;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.wiz-cat-item {
  display: block;
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
  font-size: .93rem;
  color: #0f172a;
  cursor: pointer;
}
.wiz-cat-item:hover { background: rgba(7,60,191,.06); color: #073CBF; }
.wiz-cat-sep { height: 1px; background: #e8ecf3; margin: 4px 0; }
.wiz-cat-item--new { color: #073CBF; font-weight: 700; }
.wiz-cat-loading { padding: 10px 16px; color: #94a3b8; font-size: .9rem; }
.wiz-cat-new-wrap { margin-top: 6px; }
