/* ============================================================
   A3 — Devis & Chiffrage
   Tous les styles sont scopés sous #view-devis pour éviter
   les conflits avec le reste de l'app.
   ============================================================ */

#view-devis {
  --dv-primary: #4F46E5;
  --dv-primary-light: #EEF2FF;
  --dv-primary-dark: #4338CA;
  --dv-text: #0F172A;
  --dv-text-muted: #64748B;
  --dv-border: #E2E8F0;
  --dv-border-light: #F1F5F9;
  --dv-bg: #F1F5F9;
  --dv-white: #FFFFFF;
  --dv-success: #10B981;
  --dv-success-light: #D1FAE5;
  --dv-success-dark: #047857;
  --dv-danger: #EF4444;
  --dv-danger-light: #FEE2E2;
  --dv-warn: #F59E0B;
  --dv-warn-light: #FEF3C7;
  --dv-orange: #FB923C;
  --dv-orange-light: #FFEDD5;
  background: var(--dv-bg);
  color: var(--dv-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

#view-devis .dv-header {
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--dv-border);
  display: flex; align-items: center; justify-content: space-between;
}
#view-devis .dv-breadcrumb {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--dv-text-muted);
}
#view-devis .dv-breadcrumb-title {
  color: var(--dv-text); font-weight: 700; font-size: 15px;
}

/* Status badge */
#view-devis .dv-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 700;
  margin-left: 10px;
  border: 1px solid transparent;
}
#view-devis .dv-status-badge .status-dot {
  width: 6px; height: 6px; border-radius: 50%;
}
#view-devis .dv-status-badge.brouillon { background: var(--dv-border-light); color: var(--dv-text-muted); border-color: var(--dv-border); }
#view-devis .dv-status-badge.brouillon .status-dot { background: var(--dv-text-muted); }
#view-devis .dv-status-badge.envoye { background: #DBEAFE; color: #1E40AF; border-color: #BFDBFE; }
#view-devis .dv-status-badge.envoye .status-dot { background: #3B82F6; }
#view-devis .dv-status-badge.accepte { background: var(--dv-success-light); color: var(--dv-success-dark); border-color: rgba(16, 185, 129, .3); }
#view-devis .dv-status-badge.accepte .status-dot { background: var(--dv-success); }
#view-devis .dv-status-badge.refuse { background: var(--dv-danger-light); color: #991B1B; border-color: rgba(239, 68, 68, .3); }
#view-devis .dv-status-badge.refuse .status-dot { background: var(--dv-danger); }
#view-devis .dv-status-badge.transforme { background: var(--dv-primary-light); color: var(--dv-primary-dark); border-color: #C7D2FE; }
#view-devis .dv-status-badge.transforme .status-dot { background: var(--dv-primary); }

/* Content area */
#view-devis .dv-content {
  flex: 1;
  padding: 24px 28px 60px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* Profile recap (top banner showing TJM from A2) */
#view-devis .dv-profile-recap {
  background: var(--dv-primary-light);
  border: 1px solid #C7D2FE;
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 24px;
  display: flex; align-items: center; gap: 18px;
  font-size: 12.5px;
}
#view-devis .dv-profile-recap-icon {
  width: 36px; height: 36px;
  background: #fff;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dv-primary);
  flex-shrink: 0;
}
#view-devis .dv-profile-recap-content { flex: 1; }
#view-devis .dv-profile-recap-title {
  font-size: 11.5px; font-weight: 700;
  color: var(--dv-primary-dark);
  text-transform: uppercase; letter-spacing: .4px;
  margin-bottom: 2px;
}
#view-devis .dv-profile-recap-data { color: var(--dv-text); line-height: 1.5; }
#view-devis .dv-profile-recap-data strong {
  color: var(--dv-primary-dark); font-weight: 800;
  font-variant-numeric: tabular-nums;
}
#view-devis .dv-profile-recap.empty {
  background: var(--dv-warn-light);
  border-color: #FCD34D;
}
#view-devis .dv-profile-recap.empty .dv-profile-recap-icon { color: #92400E; }
#view-devis .dv-profile-recap.empty .dv-profile-recap-title { color: #92400E; }

/* Devis info card */
#view-devis .dv-info-card {
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-info-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
@media (max-width: 900px) {
  #view-devis .dv-info-row { grid-template-columns: repeat(2, 1fr); }
}
#view-devis .dv-field { display: flex; flex-direction: column; gap: 4px; }
#view-devis .dv-field label {
  font-size: 11px; font-weight: 700;
  color: var(--dv-text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}
#view-devis .dv-field input,
#view-devis .dv-field select {
  padding: 9px 12px;
  border: 1.5px solid var(--dv-border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--dv-text);
  background: #fff;
}
#view-devis .dv-field input:hover,
#view-devis .dv-field select:hover { border-color: var(--dv-primary); }
#view-devis .dv-field input:focus,
#view-devis .dv-field select:focus {
  outline: none; border-color: var(--dv-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
#view-devis .dv-field input[readonly] {
  background: var(--dv-bg); color: var(--dv-text-muted); font-weight: 600;
}

/* Lines section */
#view-devis .dv-lines-section {
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-lines-header {
  padding: 14px 22px;
  background: var(--dv-bg);
  border-bottom: 1px solid var(--dv-border);
  display: flex; align-items: center; justify-content: space-between;
}
#view-devis .dv-lines-title {
  font-size: 13px; font-weight: 700;
  color: var(--dv-text);
  text-transform: uppercase; letter-spacing: .5px;
}
#view-devis .dv-lines-table {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) 70px 160px 110px 130px 100px 100px;
  gap: 0;
}
#view-devis .dv-lines-th {
  padding: 12px 14px;
  background: var(--dv-bg);
  border-bottom: 1px solid var(--dv-border);
  font-size: 11px; font-weight: 700;
  color: var(--dv-text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}
#view-devis .dv-lines-th.center { text-align: center; }
#view-devis .dv-lines-th.right  { text-align: right; }

#view-devis .dv-line-cell {
  padding: 14px 14px;
  border-bottom: 1px solid var(--dv-border-light);
  display: flex; align-items: center;
}
#view-devis .dv-line-cell.center { justify-content: center; }
#view-devis .dv-line-cell.right  { justify-content: flex-end; }
#view-devis .dv-line-cell input,
#view-devis .dv-line-cell select {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--dv-border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--dv-text);
  font-family: inherit;
}
#view-devis .dv-line-cell select { cursor: pointer; }
#view-devis .dv-line-cell input:hover, #view-devis .dv-line-cell select:hover { border-color: var(--dv-primary); }
#view-devis .dv-line-cell input:focus, #view-devis .dv-line-cell select:focus {
  outline: none; border-color: var(--dv-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
#view-devis .dv-line-cell .input-money,
#view-devis .dv-line-cell .input-qty {
  text-align: right; font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
#view-devis .dv-line-cell .input-money::-webkit-outer-spin-button,
#view-devis .dv-line-cell .input-money::-webkit-inner-spin-button,
#view-devis .dv-line-cell .input-qty::-webkit-outer-spin-button,
#view-devis .dv-line-cell .input-qty::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
#view-devis .dv-line-total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--dv-text); text-align: right; width: 100%;
}

/* Marge badge */
#view-devis .dv-marge-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 16px;
  font-size: 11.5px; font-weight: 700;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
}
#view-devis .dv-marge-badge:hover { transform: translateY(-1px); }
#view-devis .dv-marge-badge .dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
#view-devis .dv-marge-badge.excellent     { background: var(--dv-success-light); color: var(--dv-success-dark); border-color: rgba(16, 185, 129, .25); }
#view-devis .dv-marge-badge.excellent     .dot { background: var(--dv-success); }
#view-devis .dv-marge-badge.tres_bien     { background: #ECFDF5; color: #065F46; border-color: rgba(16, 185, 129, .2); }
#view-devis .dv-marge-badge.tres_bien     .dot { background: #34D399; }
#view-devis .dv-marge-badge.ok            { background: var(--dv-warn-light); color: #92400E; border-color: rgba(245, 158, 11, .25); }
#view-devis .dv-marge-badge.ok            .dot { background: var(--dv-warn); }
#view-devis .dv-marge-badge.tout_juste    { background: var(--dv-orange-light); color: #9A3412; border-color: rgba(251, 146, 60, .25); }
#view-devis .dv-marge-badge.tout_juste    .dot { background: var(--dv-orange); }
#view-devis .dv-marge-badge.sous_objectif { background: var(--dv-danger-light); color: #991B1B; border-color: rgba(239, 68, 68, .25); }
#view-devis .dv-marge-badge.sous_objectif .dot { background: var(--dv-danger); }
#view-devis .dv-marge-badge.unset         { background: var(--dv-border-light); color: var(--dv-text-muted); border-color: var(--dv-border); }
#view-devis .dv-marge-badge.unset         .dot { background: var(--dv-text-muted); }
#view-devis .dv-marge-badge.frais         { background: var(--dv-primary-light); color: var(--dv-primary-dark); border-color: #C7D2FE; }
#view-devis .dv-marge-badge.frais         .dot { background: var(--dv-primary); }

/* Line actions */
#view-devis .dv-line-actions { display: flex; gap: 4px; justify-content: center; }
#view-devis .dv-line-action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--dv-text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .12s;
}
#view-devis .dv-line-action-btn:hover { background: var(--dv-bg); color: var(--dv-primary); border-color: var(--dv-border); }
#view-devis .dv-line-action-btn.danger:hover { color: var(--dv-danger); background: var(--dv-danger-light); border-color: rgba(239, 68, 68, .2); }
#view-devis .dv-line-action-btn.frais-active {
  background: var(--dv-primary-light); border-color: #C7D2FE; color: var(--dv-primary);
}
#view-devis .dv-line-action-btn.frais-active:hover { background: var(--dv-primary); color: #fff; }

/* Lines footer */
#view-devis .dv-lines-footer {
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--dv-bg);
}
#view-devis .dv-add-line-btn {
  background: #fff;
  border: 1.5px dashed var(--dv-border);
  color: var(--dv-text-muted);
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: all .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
#view-devis .dv-add-line-btn:hover { border-color: var(--dv-primary); color: var(--dv-primary); border-style: solid; }

/* Bottom grid */
#view-devis .dv-bottom-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { #view-devis .dv-bottom-grid { grid-template-columns: 1fr; } }

/* Rentability card */
#view-devis .dv-renta-card {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid #FCD34D;
  border-radius: 12px;
  padding: 20px 22px;
  position: relative;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-renta-card.excellent     { background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%); border-color: rgba(16, 185, 129, .4); }
#view-devis .dv-renta-card.tres_bien     { background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%); border-color: rgba(16, 185, 129, .3); }
#view-devis .dv-renta-card.ok            { background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%); border-color: rgba(245, 158, 11, .35); }
#view-devis .dv-renta-card.tout_juste    { background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%); border-color: rgba(251, 146, 60, .35); }
#view-devis .dv-renta-card.sous_objectif { background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%); border-color: rgba(239, 68, 68, .4); }
#view-devis .dv-renta-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
#view-devis .dv-renta-title { font-size: 13px; font-weight: 700; color: var(--dv-text); text-transform: uppercase; letter-spacing: .5px; display: inline-flex; align-items: center; gap: 8px; }
#view-devis .dv-renta-title svg { color: var(--dv-primary); }
#view-devis .dv-renta-verdict { font-size: 12px; font-weight: 800; padding: 5px 12px; border-radius: 14px; display: inline-flex; align-items: center; gap: 5px; }
#view-devis .dv-renta-verdict .v-dot { width: 7px; height: 7px; border-radius: 50%; }
#view-devis .dv-renta-verdict.excellent     { background: var(--dv-success);  color: #fff; }
#view-devis .dv-renta-verdict.excellent     .v-dot { background: #fff; }
#view-devis .dv-renta-verdict.tres_bien     { background: #34D399; color: #fff; }
#view-devis .dv-renta-verdict.tres_bien     .v-dot { background: #fff; }
#view-devis .dv-renta-verdict.ok            { background: var(--dv-warn);     color: #fff; }
#view-devis .dv-renta-verdict.ok            .v-dot { background: #fff; }
#view-devis .dv-renta-verdict.tout_juste    { background: var(--dv-orange);   color: #fff; }
#view-devis .dv-renta-verdict.tout_juste    .v-dot { background: #fff; }
#view-devis .dv-renta-verdict.sous_objectif { background: var(--dv-danger);   color: #fff; }
#view-devis .dv-renta-verdict.sous_objectif .v-dot { background: #fff; }
#view-devis .dv-renta-verdict.unset         { background: var(--dv-border);   color: var(--dv-text-muted); }
#view-devis .dv-renta-verdict.unset         .v-dot { background: var(--dv-text-muted); }
#view-devis .dv-renta-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; margin-bottom: 14px; }
#view-devis .dv-renta-stat { display: flex; flex-direction: column; gap: 2px; }
#view-devis .dv-renta-stat-label { font-size: 11px; font-weight: 600; color: var(--dv-text-muted); text-transform: uppercase; letter-spacing: .4px; }
#view-devis .dv-renta-stat-value { font-size: 18px; font-weight: 800; color: var(--dv-text); letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
#view-devis .dv-renta-stat-sub { font-size: 11.5px; color: var(--dv-text-muted); font-weight: 500; margin-top: 2px; }
#view-devis .dv-renta-marge .dv-renta-stat-value { color: var(--dv-success-dark); font-size: 22px; }
#view-devis .dv-renta-card.tres_bien     .dv-renta-marge .dv-renta-stat-value { color: #047857; }
#view-devis .dv-renta-card.ok            .dv-renta-marge .dv-renta-stat-value { color: #92400E; }
#view-devis .dv-renta-card.tout_juste    .dv-renta-marge .dv-renta-stat-value { color: #9A3412; }
#view-devis .dv-renta-card.sous_objectif .dv-renta-marge .dv-renta-stat-value { color: #991B1B; }
#view-devis .dv-renta-card.unset         .dv-renta-marge .dv-renta-stat-value { color: var(--dv-text-muted); }
#view-devis .dv-renta-explain { border-top: 1px dashed rgba(120, 53, 15, .25); padding-top: 12px; font-size: 12.5px; color: var(--dv-text); line-height: 1.55; }
#view-devis .dv-renta-explain strong { color: var(--dv-text); font-weight: 700; }
#view-devis .dv-renta-card.excellent     .dv-renta-explain { border-top-color: rgba(16, 185, 129, .25); }
#view-devis .dv-renta-card.tres_bien     .dv-renta-explain { border-top-color: rgba(16, 185, 129, .2); }
#view-devis .dv-renta-card.tout_juste    .dv-renta-explain { border-top-color: rgba(251, 146, 60, .25); }
#view-devis .dv-renta-card.sous_objectif .dv-renta-explain { border-top-color: rgba(239, 68, 68, .25); }

/* Renta secondary (charges & URSSAF coverage) */
#view-devis .dv-renta-secondary {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#view-devis .dv-renta-secondary.ok {
  background: rgba(16, 185, 129, .12);
  color: var(--dv-success-dark);
  border: 1px solid rgba(16, 185, 129, .25);
}
#view-devis .dv-renta-secondary.ok svg { color: var(--dv-success); flex-shrink: 0; }
#view-devis .dv-renta-secondary.danger {
  background: rgba(239, 68, 68, .1);
  color: #991B1B;
  border: 1px solid rgba(239, 68, 68, .3);
}
#view-devis .dv-renta-secondary.danger svg { color: var(--dv-danger); flex-shrink: 0; }
#view-devis .dv-renta-secondary strong { font-weight: 700; }

/* Totals card */
#view-devis .dv-totals-card {
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-totals-title { font-size: 13px; font-weight: 700; color: var(--dv-text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 14px; }
#view-devis .dv-totals-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--dv-border-light); font-size: 13.5px; }
#view-devis .dv-totals-row:last-child { border-bottom: none; }
#view-devis .dv-totals-row.total { padding-top: 14px; border-top: 2px solid var(--dv-text); margin-top: 6px; font-size: 18px; font-weight: 800; color: var(--dv-text); }
#view-devis .dv-totals-label { color: var(--dv-text-muted); }
#view-devis .dv-totals-row.total .dv-totals-label { color: var(--dv-text); }
#view-devis .dv-totals-value { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--dv-text); }

/* Action bar (status-adaptive) */
#view-devis .dv-action-bar {
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-action-bar.accepte { background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%); border-color: rgba(16, 185, 129, .35); }
#view-devis .dv-action-bar.refuse { background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%); border-color: rgba(239, 68, 68, .35); }
#view-devis .dv-action-bar.transforme { background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%); border-color: #C7D2FE; }
#view-devis .dv-action-bar-info { flex: 1; min-width: 240px; }
#view-devis .dv-action-bar-title { font-size: 14.5px; font-weight: 800; color: var(--dv-text); display: inline-flex; align-items: center; gap: 8px; margin-bottom: 3px; }
#view-devis .dv-action-bar-desc { font-size: 13px; color: var(--dv-text-muted); line-height: 1.5; }
#view-devis .dv-action-bar-desc strong { color: var(--dv-text); font-weight: 700; }
#view-devis .dv-action-bar-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }

/* Buttons */
#view-devis .dv-btn {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .12s; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
#view-devis .dv-btn-primary  { background: var(--dv-primary); color: #fff; }
#view-devis .dv-btn-primary:hover  { background: var(--dv-primary-dark); }
#view-devis .dv-btn-primary:disabled { background: var(--dv-border); color: var(--dv-text-muted); cursor: not-allowed; }
#view-devis .dv-btn-outline  { background: #fff; border: 1.5px solid var(--dv-border); color: var(--dv-text); }
#view-devis .dv-btn-outline:hover { border-color: var(--dv-primary); color: var(--dv-primary); }
#view-devis .dv-btn-ghost    { background: transparent; border: 1px solid transparent; color: var(--dv-text-muted); }
#view-devis .dv-btn-ghost:hover { color: var(--dv-text); background: var(--dv-bg); }
#view-devis .dv-btn-success  { background: var(--dv-success); color: #fff; }
#view-devis .dv-btn-success:hover { background: var(--dv-success-dark); }
#view-devis .dv-btn-danger-outline { background: #fff; border: 1.5px solid rgba(239, 68, 68, .3); color: var(--dv-danger); }
#view-devis .dv-btn-danger-outline:hover { background: var(--dv-danger-light); border-color: var(--dv-danger); }

/* Anti-double-clic visuel : ajouté par JS via _setBusy() pendant les opérations
   asynchrones (saveDevis, transformDevis). Grise tous les boutons d'action et
   bloque les clics — le cursor:wait signale clairement que l'app travaille. */
#view-devis.is-busy .dv-btn,
#view-devis.is-busy button[data-action] {
  opacity: .55;
  pointer-events: none;
  cursor: wait;
}

/* Facture link */
#view-devis .dv-facture-link {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1.5px solid #C7D2FE;
  color: var(--dv-primary-dark);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px; font-weight: 700;
  text-decoration: none;
  transition: all .12s;
}
#view-devis .dv-facture-link:hover { border-color: var(--dv-primary); background: var(--dv-primary-light); }
#view-devis .dv-facture-link svg { color: var(--dv-primary); }

/* Conditions card */
#view-devis .dv-conditions-card {
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-conditions-title { font-size: 13px; font-weight: 700; color: var(--dv-text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
#view-devis .dv-conditions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { #view-devis .dv-conditions-grid { grid-template-columns: 1fr; } }
#view-devis .dv-conditions-field { display: flex; flex-direction: column; gap: 4px; }
#view-devis .dv-conditions-field label { font-size: 11px; font-weight: 700; color: var(--dv-text-muted); text-transform: uppercase; letter-spacing: .5px; }
#view-devis .dv-conditions-field textarea,
#view-devis .dv-conditions-field input {
  padding: 9px 12px;
  border: 1.5px solid var(--dv-border);
  border-radius: 8px;
  font-size: 13px; font-family: inherit;
  color: var(--dv-text); background: #fff;
  resize: vertical;
}
#view-devis .dv-conditions-field textarea:hover, #view-devis .dv-conditions-field input:hover { border-color: var(--dv-primary); }
#view-devis .dv-conditions-field textarea:focus, #view-devis .dv-conditions-field input:focus {
  outline: none; border-color: var(--dv-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

/* Modal */
#view-devis .dv-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
#view-devis .dv-modal-overlay.active { display: flex; }
#view-devis .dv-modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%; max-width: 560px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
  animation: dvModalPop .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes dvModalPop {
  0% { opacity: 0; transform: scale(.95); }
  100% { opacity: 1; transform: scale(1); }
}
#view-devis .dv-modal-header { padding: 18px 24px 14px; border-bottom: 1px solid var(--dv-border); display: flex; align-items: center; justify-content: space-between; }
#view-devis .dv-modal-title-block { display: flex; flex-direction: column; gap: 2px; }
#view-devis .dv-modal-title { font-size: 16px; font-weight: 800; color: var(--dv-text); display: inline-flex; align-items: center; gap: 8px; }
#view-devis .dv-modal-title svg { color: var(--dv-primary); }
#view-devis .dv-modal-subtitle { font-size: 12px; color: var(--dv-text-muted); }
#view-devis .dv-modal-close { background: none; border: none; color: var(--dv-text-muted); cursor: pointer; padding: 4px; border-radius: 6px; }
#view-devis .dv-modal-close:hover { color: var(--dv-text); background: var(--dv-bg); }
#view-devis .dv-modal-body { padding: 20px 24px; }
#view-devis .dv-modal-field { margin-bottom: 16px; }
#view-devis .dv-modal-field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--dv-text); margin-bottom: 6px; }
#view-devis .dv-modal-input-row { display: flex; align-items: center; gap: 10px; }
#view-devis .dv-modal-input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--dv-border);
  border-radius: 9px;
  font-size: 16px; font-weight: 700;
  font-family: inherit;
  color: var(--dv-text);
  text-align: right;
  background: #fff;
  -moz-appearance: textfield;
}
#view-devis .dv-modal-input::-webkit-outer-spin-button,
#view-devis .dv-modal-input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
#view-devis .dv-modal-input:hover { border-color: var(--dv-primary); }
#view-devis .dv-modal-input:focus { outline: none; border-color: var(--dv-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
#view-devis select.dv-modal-input,
#view-devis input[type="date"].dv-modal-input {
  text-align: left; font-size: 14px; cursor: pointer; background-color: #fff;
}
#view-devis .dv-modal-input-suffix { font-size: 13px; color: var(--dv-text-muted); font-weight: 600; }
#view-devis .dv-modal-info-card {
  background: var(--dv-primary-light);
  border: 1px solid #C7D2FE;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 12.5px; color: var(--dv-text);
  line-height: 1.55;
}
#view-devis .dv-modal-info-card strong {
  color: var(--dv-primary-dark); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#view-devis .dv-marge-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
#view-devis .dv-marge-preset {
  padding: 11px 8px;
  border: 1.5px solid var(--dv-border);
  border-radius: 8px;
  background: #fff;
  text-align: center;
  cursor: pointer;
  transition: all .12s;
  font-family: inherit;
}
#view-devis .dv-marge-preset:hover { border-color: var(--dv-primary); }
#view-devis .dv-marge-preset.active { border-color: var(--dv-primary); background: var(--dv-primary-light); }
#view-devis .dv-marge-preset-pct { font-size: 15px; font-weight: 800; color: var(--dv-text); display: block; }
#view-devis .dv-marge-preset.active .dv-marge-preset-pct { color: var(--dv-primary-dark); }
#view-devis .dv-marge-preset-label { font-size: 10.5px; color: var(--dv-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
#view-devis .dv-modal-result {
  background: linear-gradient(135deg, var(--dv-primary) 0%, var(--dv-primary-dark) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 4px;
}
#view-devis .dv-modal-result-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; opacity: .9; margin-bottom: 6px; }
#view-devis .dv-modal-result-value { font-size: 28px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
#view-devis .dv-modal-result-detail { font-size: 12px; opacity: .85; margin-top: 4px; }
#view-devis .dv-modal-footer { padding: 16px 24px; border-top: 1px solid var(--dv-border); display: flex; justify-content: flex-end; gap: 10px; }

/* List view (devis list page) */
#view-devis .dv-list-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap; gap: 10px;
}
#view-devis .dv-list-title { font-size: 22px; font-weight: 800; color: var(--dv-text); }
#view-devis .dv-list-subtitle { font-size: 13px; color: var(--dv-text-muted); margin-top: 2px; }
#view-devis .dv-list-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#view-devis .dv-filter-pill {
  padding: 6px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1.5px solid var(--dv-border);
  color: var(--dv-text-muted);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
#view-devis .dv-filter-pill:hover { border-color: var(--dv-primary); color: var(--dv-primary); }
#view-devis .dv-filter-pill.active { background: var(--dv-primary); color: #fff; border-color: var(--dv-primary); }

#view-devis .dv-list-card {
  background: #fff;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}
#view-devis .dv-list-row {
  display: grid;
  grid-template-columns: 130px 1.4fr 140px 100px 110px 120px 40px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--dv-border-light);
  cursor: pointer;
  transition: background .1s;
}
#view-devis .dv-list-row:hover { background: var(--dv-bg); }
#view-devis .dv-list-row.header {
  background: var(--dv-bg);
  cursor: default;
  font-size: 11px; font-weight: 700;
  color: var(--dv-text-muted);
  text-transform: uppercase; letter-spacing: .5px;
}
#view-devis .dv-list-row.header:hover { background: var(--dv-bg); }
#view-devis .dv-list-numero { font-weight: 700; color: var(--dv-text); font-variant-numeric: tabular-nums; }
#view-devis .dv-list-client { color: var(--dv-text); }
#view-devis .dv-list-date { color: var(--dv-text-muted); font-size: 12.5px; }
#view-devis .dv-list-total { font-weight: 700; color: var(--dv-text); font-variant-numeric: tabular-nums; text-align: right; }
#view-devis .dv-list-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--dv-text-muted);
}
#view-devis .dv-list-empty-icon {
  width: 70px; height: 70px;
  background: var(--dv-primary-light);
  border-radius: 50%;
  margin: 0 auto 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--dv-primary);
}
#view-devis .dv-list-empty h3 { font-size: 17px; font-weight: 800; color: var(--dv-text); margin-bottom: 6px; }
#view-devis .dv-list-empty p { font-size: 13px; color: var(--dv-text-muted); margin-bottom: 20px; line-height: 1.55; }

/* ====== Coach IA Claude card ====== */
#view-devis .dv-coach-card {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid #FCD34D;
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
#view-devis .dv-coach-info { flex: 1; min-width: 240px; }
#view-devis .dv-coach-title {
  font-size: 14.5px; font-weight: 800; color: var(--dv-text);
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 3px;
}
#view-devis .dv-coach-title svg { color: var(--dv-primary); }
#view-devis .dv-coach-desc { font-size: 13px; color: var(--dv-text-muted); line-height: 1.5; }
#view-devis .dv-coach-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }

/* Boutons de reformulation par ligne (✨) */
#view-devis .dv-reformulate-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--dv-primary);
  width: 24px; height: 24px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 4px;
  transition: all .12s;
}
#view-devis .dv-reformulate-btn:hover {
  background: var(--dv-primary-light);
  border-color: var(--dv-primary);
}
#view-devis .dv-reformulate-btn:disabled { opacity: .4; cursor: wait; }

/* AI Modal — affichage du résultat */
#view-devis .dv-ai-modal-body {
  padding: 20px 24px;
  max-height: 60vh;
  overflow-y: auto;
}
#view-devis .dv-ai-result {
  background: #fff;
  border: 1px solid var(--dv-border);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--dv-text);
  white-space: pre-wrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#view-devis .dv-ai-result strong { color: var(--dv-primary-dark); font-weight: 700; }
#view-devis .dv-ai-result code {
  background: var(--dv-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12.5px;
}
#view-devis .dv-ai-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 30px;
  color: var(--dv-text-muted);
  font-size: 13.5px;
  font-style: italic;
}
#view-devis .dv-ai-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--dv-border);
  border-top-color: var(--dv-primary);
  border-radius: 50%;
  animation: dvSpin 0.8s linear infinite;
}
@keyframes dvSpin { to { transform: rotate(360deg); } }
#view-devis .dv-ai-hint {
  margin-top: 12px;
  padding: 9px 12px;
  background: var(--dv-primary-light);
  border-radius: 7px;
  font-size: 12px;
  color: var(--dv-primary-dark);
  line-height: 1.5;
  display: flex; align-items: flex-start; gap: 8px;
}
#view-devis .dv-ai-hint svg { flex-shrink: 0; margin-top: 1px; }

/* Custom select component (dropdown blanc + bordure violette) */
.dv-cs {
  position: relative;
  display: inline-block;
  width: 100%;
}
.dv-cs-trigger {
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--dv-border, #E2E8F0);
  color: var(--dv-text, #0F172A);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dv-cs-trigger:hover { border-color: var(--dv-primary, #4F46E5); }
.dv-cs-trigger[aria-expanded="true"] {
  border-color: var(--dv-primary, #4F46E5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.dv-cs-chevron {
  color: var(--dv-text-muted, #64748B);
  transition: transform .15s;
  flex-shrink: 0;
  display: inline-flex;
}
.dv-cs-trigger[aria-expanded="true"] .dv-cs-chevron {
  transform: rotate(180deg);
  color: var(--dv-primary, #4F46E5);
}
.dv-cs-menu {
  position: fixed;
  background: #fff;
  border: 1.5px solid var(--dv-primary, #4F46E5);
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .12), 0 0 0 4px rgba(79, 70, 229, .08);
  z-index: 9999;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
.dv-cs-menu-inner {
  max-height: 90px;
  overflow-y: auto;
  padding: 3px;
  list-style: none;
  margin: 0;
  scrollbar-width: none;
}
.dv-cs-menu-inner::-webkit-scrollbar { display: none; }
.dv-cs-option {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--dv-text, #0F172A);
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.25;
}
.dv-cs-option:hover {
  background: var(--dv-primary-light, #EEF2FF);
  color: var(--dv-primary-dark, #4338CA);
}
.dv-cs-option.selected {
  background: var(--dv-primary-light, #EEF2FF);
  color: var(--dv-primary-dark, #4338CA);
  font-weight: 700;
}
.dv-cs-option-content {
  display: flex; flex-direction: column;
  align-items: flex-start;
  flex: 1; min-width: 0; overflow: hidden;
}
.dv-cs-option-label {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.dv-cs-option.selected .dv-cs-option-label { font-weight: 700; }
.dv-cs-option-sub {
  font-size: 10.5px;
  color: var(--dv-text-muted, #64748B);
  font-weight: 500;
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dv-cs-option.selected .dv-cs-option-sub {
  color: var(--dv-primary-dark, #4338CA);
  opacity: .8;
}

/* Toast (réutilise celui de l'app si présent) */
#view-devis .dv-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--dv-text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 12px 36px rgba(0,0,0,.2);
  opacity: 0;
  transition: all .25s ease-out;
  z-index: 2000;
  display: inline-flex; align-items: center; gap: 10px;
  pointer-events: none;
}
#view-devis .dv-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
