/* =============================================================================
   AURYVO Business — Ventes : un seul parcours, du devis au paiement (views/ventes.js)
   Les étapes en tête (compteurs qui filtrent), une liste unique dessous, le client dans un tiroir.
   Bleu = signé (validé) ; vert = payé ; rouge = en retard (alerte) ; pointillé = brouillon (inachevé).
   ============================================================================= */
.vn-page { container: vn-page / inline-size; }
.vn-tete { margin-bottom: 20px; }
.vn-nouveaux { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- le parcours : six étapes, six compteurs ---------- */
.vn-parcours { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.vn-etape { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; min-height: 96px; padding: 14px 16px;
  text-align: left; border-radius: var(--r-md); border: 1px solid var(--panel-line); background: var(--card); color: var(--ink); box-shadow: var(--sh-card);
  font: inherit; cursor: pointer; transition: transform .25s var(--spring), opacity .2s, box-shadow .2s; }
.vn-etape:hover { transform: translateY(-2px); }
.vn-etape:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.vn-e-lib { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; line-height: 1.25; color: var(--ink-2); }
.vn-e-lib b { flex-shrink: 0; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--pill); background: var(--card-2); color: var(--ink);
  display: inline-grid; place-items: center; font-size: 12px; }
.vn-e-mt { font-family: var(--display); font-size: 24px; font-weight: 500; letter-spacing: -.035em; line-height: 1; white-space: nowrap; }
.vn-etape.vide { box-shadow: none; }
.vn-etape.vide .vn-e-mt { color: var(--ink-3); }
.vn-parcours.filtre .vn-etape:not(.actif) { opacity: .5; }
.vn-parcours.filtre .vn-etape:not(.actif):hover { opacity: 1; }
.vn-etape.actif { box-shadow: 0 0 0 2px var(--ink); }

.vn-e-signes:not(.vide) .vn-e-lib b { background: var(--black); color: var(--on-black); }
.vn-e-brouillons { background: var(--inacheve-motif), var(--card); outline: var(--inacheve-contour); outline-offset: var(--inacheve-decal); box-shadow: none; }
.vn-e-brouillons .vn-e-mt { color: var(--ink-2); }
.vn-e-encaisser.actif { box-shadow: 0 0 0 2px var(--ink); }
.vn-e-retard:not(.vide) { background: var(--danger-soft); border-color: transparent; box-shadow: none; }
.vn-e-retard:not(.vide) .vn-e-lib { color: var(--danger); }
.vn-e-retard:not(.vide) .vn-e-lib b { background: var(--danger); color: #fff; }
.vn-e-retard:not(.vide) .vn-e-mt { color: var(--danger); }
.vn-e-retard.actif { box-shadow: 0 0 0 2px var(--danger); }
.vn-e-payees:not(.vide) { background: var(--green-soft); border-color: transparent; box-shadow: none; }
.vn-e-payees:not(.vide) .vn-e-mt { color: var(--green); }
.vn-e-payees.actif { box-shadow: 0 0 0 2px var(--green); }

.vn-barre { display: flex; align-items: center; gap: 12px; min-height: 34px; margin: 0 0 12px; }
.vn-puce { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px 0 10px; border: 0; border-radius: var(--pill);
  background: var(--black); color: var(--on-black); font: 600 12.5px var(--text); cursor: pointer; }

/* ---------- la liste unique ---------- */
.vn-liste { padding: 6px; margin-bottom: 72px; }   /* la dernière ligne reste dégagée de la bulle de Sophystia */
.vn-ligne { display: grid; grid-template-columns: 132px minmax(0, 1fr) 132px 200px 296px; align-items: center; gap: 16px; min-height: 64px;
  padding: 10px 12px 10px 16px; border-radius: var(--r-sm); cursor: pointer; transition: background .15s; }
.vn-ligne { position: relative; }
.vn-ligne:hover { background: var(--card-2); }
.vn-ligne.eclair { animation: vn-eclair 2.4s var(--ease) both; }
@keyframes vn-eclair { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }

.vn-num { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vn-type { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.vn-num a { font-weight: 700; font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vn-num a:hover { text-decoration: underline; text-underline-offset: 3px; }
.vn-qui { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.vn-client { max-width: 100%; padding: 0; border: 0; background: none; color: var(--ink); font: 600 14px var(--text); text-align: left; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; overflow-wrap: anywhere; }
.vn-client:hover { text-decoration-color: currentColor; }
.vn-objet { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; overflow-wrap: anywhere; }
.vn-mt { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; text-align: right; }
.vn-mt b { font-size: 14.5px; font-weight: 700; white-space: nowrap; }
.vn-mt .xs { white-space: nowrap; }
.vn-etat { min-width: 0; }
.vn-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.vn-actions .btn-sm { flex-shrink: 0; white-space: nowrap; }
/* un bouton qui se déplie ne se tasse jamais : il déborde vers la gauche, par-dessus le vide de la colonne d'état */
.vn-actions .btn-deplie { flex-shrink: 0; position: relative; }
.vn-actions .btn-deplie:hover, .vn-actions .btn-deplie:focus-visible { z-index: 2; }
.vn-alerte { background: var(--danger); color: #fff; }
.vn-alerte:hover:not(:disabled) { box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--danger) 80%, transparent); }

/* l'étape d'un document : une pastille, la couleur porte le sens */
.vn-pastille { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 5px 11px 5px 10px; border-radius: var(--pill); background: var(--card-2);
  color: var(--ink-2); font-size: 12px; font-weight: 600; line-height: 1.3; }
.vn-pastille::before { content: ""; flex-shrink: 0; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.vn-pastille.p-brouillon { background: transparent; outline: var(--inacheve-contour); outline-offset: -1.5px; }
.vn-pastille.p-devis.urgent { color: var(--amber); background: var(--amber-soft); }
.vn-pastille.p-signe { color: var(--ink); background: var(--card-3); }
.vn-pastille.p-encaisser { color: var(--ink); }
.vn-pastille.p-retard { color: var(--danger); background: var(--danger-soft); }
.vn-pastille.p-payee { color: var(--green); background: var(--green-soft); }
.vn-pastille.p-fini { color: var(--ink-3); background: transparent; padding-left: 0; }
.vn-t-retard .vn-mt b { color: var(--danger); }
.vn-t-brouillon .vn-num a, .vn-t-fini .vn-mt b { color: var(--ink-2); }

.vn-plus { display: block; width: calc(100% - 12px); margin: 8px 6px 4px; height: 44px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: none;
  color: var(--ink); font: 600 13px var(--text); cursor: pointer; }
.vn-plus:hover { background: var(--card-2); }

/* ---------- fenêtre « acompte » ---------- */
.vn-acompte { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 6px; padding: 16px 18px; border-radius: var(--r-md); background: var(--card-2); }
.vn-acompte b { font-family: var(--display); font-size: 28px; font-weight: 500; letter-spacing: -.03em; }

/* ---------- le tiroir du client ---------- */
.vn-ident { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.vn-ident > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.vn-mono { flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--black); color: var(--on-black);
  font: 700 14px var(--text); letter-spacing: .02em; }
.vn-chiffres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.vn-chiffres > div { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--card-2); min-width: 0; }
.vn-chiffres span { font-size: 11.5px; font-weight: 600; color: var(--ink-3); line-height: 1.25; }
.vn-chiffres b { font-size: 15px; font-weight: 700; white-space: nowrap; }
.vn-chiffres .alerte { background: var(--danger-soft); }
.vn-chiffres .alerte span, .vn-chiffres .alerte b { color: var(--danger); }
.vn-retards { display: flex; align-items: flex-start; gap: 9px; margin: 0 0 12px; padding: 11px 14px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger);
  font-size: 13px; font-weight: 600; line-height: 1.4; }
.vn-retards svg.i { flex-shrink: 0; margin-top: 1px; }
.vn-infos { display: flex; flex-direction: column; margin: 4px 0 20px; }
.vn-info { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding: 10px 0; font-size: 13.5px; }
.vn-info + .vn-info { box-shadow: inset 0 1px 0 var(--line); }
.vn-info > span:first-child { color: var(--ink-3); font-weight: 600; font-size: 12.5px; padding-top: 1px; }
.vn-info > span:last-child { overflow-wrap: anywhere; }
.vn-info a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.vn-sous-titre { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font: 700 14px var(--text); }
.vn-sous-titre .faint { font-weight: 600; }
.vn-docs { display: flex; flex-direction: column; border-radius: var(--r-md); background: var(--card-2); padding: 4px; }
.vn-doc { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t mt" "o e"; align-items: center; gap: 4px 12px; padding: 11px 12px;
  border-radius: var(--r-sm); transition: background .15s; }
.vn-doc { position: relative; }
.vn-doc + .vn-doc::before, .vn-ligne + .vn-ligne::before { content: ""; position: absolute; top: 0; left: 12px; right: 12px; height: 1px; background: var(--line); }
.vn-doc:hover { background: var(--card-3); }
.vn-doc:hover::before, .vn-doc:hover + .vn-doc::before, .vn-ligne:hover::before, .vn-ligne:hover + .vn-ligne::before { opacity: 0; }
.vn-doc-t { overflow-wrap: anywhere; grid-area: t; font-size: 13.5px; font-weight: 600; }
.vn-doc-mt { grid-area: mt; justify-self: end; font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.vn-doc-o { grid-area: o; min-width: 0; overflow-wrap: anywhere; }
.vn-doc-e { grid-area: e; justify-self: end; }
.vn-doc-e .vn-pastille { font-size: 11.5px; padding: 3px 9px 3px 8px; white-space: nowrap; }
.vn-doc-e .vn-pastille.p-fini { padding-right: 0; }
.vn-docs .vn-pastille:is(.p-devis, .p-encaisser) { background: var(--card); }

/* ordinateur : le tiroir glisse depuis la droite, la liste reste visible derrière */
@media (min-width: 821px) {
  .modal-bg.vn-tiroir { justify-content: flex-end; align-items: stretch; padding: 12px; overflow: hidden; background: rgba(5, 5, 6, .32);
    backdrop-filter: none; -webkit-backdrop-filter: none; }
  :root[data-theme="light"] .modal-bg.vn-tiroir { background: rgba(30, 30, 34, .14); }
  .vn-tiroir .modal { display: flex; flex-direction: column; max-width: 460px; height: calc(100vh - 24px); height: calc(100dvh - 24px); border-radius: var(--r-lg);
    animation: vn-tiroir-in .5s var(--ease-out) both; }
  .vn-tiroir .modal-head { padding: 22px 24px 6px; gap: 12px; }
  .vn-tiroir .modal-head h2 { font-size: 23px; min-width: 0; overflow-wrap: anywhere; }
  .vn-tiroir .modal-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 24px 20px; }
  .vn-tiroir .modal-foot { border-top: 1px solid var(--line); padding: 14px 24px 18px; }
  @keyframes vn-tiroir-in { from { transform: translateX(calc(100% + 24px)); } }
}

/* page étroite (petit écran, ou barre latérale ouverte) : les étapes sur deux rangées, les actions sous la ligne.
   Mesuré sur la largeur de la page elle-même, pas sur celle de l'écran. */
@container vn-page (max-width: 1079px) {
  .vn-parcours { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container vn-page (max-width: 999px) {
  .vn-ligne { grid-template-columns: 120px minmax(0, 1fr) 124px 180px; grid-template-areas: "num qui mt etat" "act act act act"; row-gap: 8px; }
  .vn-num { grid-area: num; } .vn-qui { grid-area: qui; } .vn-mt { grid-area: mt; } .vn-etat { grid-area: etat; } .vn-actions { grid-area: act; }
  .vn-actions.rien { display: none; }
}

/* ---------- téléphone : cartes lisibles, actions au pouce ---------- */
@media (max-width: 820px) {
  .vn-tete { margin-bottom: 14px; }
  /* les deux créations restent dans la page, côte à côte (pas de « + » ambigu dans la barre) */
  .vn-nouveaux { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
  .vn-nouveaux .btn { height: 46px; padding: 0 12px; font-size: 14.5px; }
  .vn-parcours { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .vn-etape { min-height: 84px; padding: 12px 14px; gap: 10px; }
  .vn-etape:hover { transform: none; }
  .vn-e-mt { font-size: 21px; }
  .vn-page .vn-liste.card { background: none; border: 0; box-shadow: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
  .vn-ligne { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "num mt" "qui qui" "etat etat" "act act"; gap: 10px 12px;
    padding: 14px 14px 14px 16px; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--panel-line); box-shadow: var(--sh-card); }
  .vn-ligne + .vn-ligne::before { display: none; }
  .vn-ligne:hover { background: var(--card); }
  .vn-num { grid-area: num; flex-direction: row; align-items: baseline; gap: 8px; }
  .vn-qui { grid-area: qui; }
  .vn-client { font-size: 16px; }
  .vn-objet { font-size: 13.5px; }
  .vn-mt { grid-area: mt; }
  .vn-mt b { font-size: 16px; }
  .vn-etat { grid-area: etat; }
  .vn-actions { grid-area: act; flex-wrap: wrap; justify-content: stretch; gap: 8px; }
  .vn-actions.rien { display: none; }
  .vn-actions .btn-sm { order: -1; flex: 1 0 100%; height: 44px; font-size: 14px; }
  .vn-actions .btn-deplie { flex: 1 1 auto; min-width: max-content; justify-content: center; height: 44px; gap: 6px; padding: 0 14px 0 12px; font-size: 13.5px; }
  .vn-actions .btn-deplie span { max-width: none; opacity: 1; }
  .vn-plus { width: 100%; margin: 2px 0 0; height: 48px; }
  .vn-liste .empty { background: var(--card); border-radius: var(--r-md); }

  /* le tiroir devient une feuille plein écran */
  .modal-bg.vn-tiroir .modal { height: calc(100dvh - env(safe-area-inset-top) - 18px); }
  .vn-tiroir .modal-foot .btn { flex: 1 1 auto; }
  .vn-chiffres { gap: 6px; }
  .vn-chiffres > div { padding: 10px 11px; }
  .vn-chiffres b { font-size: 14px; }
  .vn-info { grid-template-columns: 92px minmax(0, 1fr); font-size: 15px; }
  .vn-doc { grid-template-areas: "t mt" "o o" "e e"; padding: 12px; row-gap: 6px; }
  .vn-doc-e { justify-self: start; }
}
@media (max-width: 380px) {
  .vn-chiffres { grid-template-columns: 1fr 1fr; }
  .vn-chiffres > div:last-child { grid-column: 1 / -1; }
}

/* =============================================================================
   01/12 — façon Things : un seul langage visuel, l'essentiel d'abord
   ============================================================================= */
/* compteurs homogènes : pas de fonds colorés ni de pastilles noires ; seuls les montants portent la couleur */
.vn-e-retard:not(.vide), .vn-e-payees:not(.vide) { background: var(--card); border-color: var(--panel-line); box-shadow: var(--sh-card); }
.vn-e-retard:not(.vide) .vn-e-lib { color: var(--ink-2); }
.vn-e-retard:not(.vide) .vn-e-lib b { background: var(--danger); color: #fff; }
.vn-e-signes:not(.vide) .vn-e-lib b { background: var(--card-2); color: var(--ink); }
.vn-e-brouillons { background: var(--card); outline: 0; box-shadow: var(--sh-card); }

/* la liste rangée comme une journée : titres de section discrets */
.vn-section { display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 16px 16px 6px; border: 0; background: none; font: 700 13px var(--text);
  color: var(--ink); text-align: left; }
.vn-section:first-child { padding-top: 8px; }
.vn-section-n { color: var(--ink-3); font-weight: 600; }
.vn-histo { cursor: pointer; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 14px; color: var(--ink-2); }
.vn-histo-v { margin-left: auto; font-weight: 600; color: var(--ink-3); }
.vn-histo:hover .vn-histo-v { color: var(--ink); }
.vn-section + .vn-ligne::before { display: none; }

/* le numéro sur une ligne (le type seulement s'il n'est pas « Facture ») */
.vn-num { flex-direction: row; align-items: baseline; gap: 6px; }
.vn-type { font-size: 12px; }

/* l'état en texte simple : rouge pour le retard, vert pour le payé, gris sinon */
.vn-statut { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.vn-statut.s-retard { color: var(--danger); }
.vn-statut.s-payee { color: var(--green); }
.vn-statut.s-devis.urgent { color: var(--amber); }
.vn-statut.s-fini { color: var(--ink-3); }
.vn-statut.s-brouillon { color: var(--ink-3); font-style: italic; }

/* une seule action visible ; les petites (lien, payée, modifier) apparaissent au survol de la ligne */
@media (hover: hover) and (min-width: 821px) {
  .vn-actions .btn-deplie { opacity: 0; transition: opacity .15s; }
  .vn-ligne:hover .vn-actions .btn-deplie, .vn-ligne:focus-within .vn-actions .btn-deplie { opacity: 1; }
}
@media (max-width: 820px) {
  .vn-section { padding: 14px 4px 2px; }
  .vn-histo { border-top: 0; }
}
.vn-barre:empty { display: none; }

/* Fiche client (tiroir), 01/12 : le retard se lit dans le chiffre en rouge, sans fond rouge ni bandeau qui le répète */
.vn-chiffres .alerte { background: var(--card-2); }
.vn-chiffres .alerte span { color: var(--ink-3); }
.vn-chiffres .alerte b { color: var(--danger); }
.vn-retards { background: none; padding: 0 2px; color: var(--ink-2); font-weight: 500; }
.vn-retards svg.i { color: var(--danger); }
