/* Listes et fiches des écrans (public/js/liste.js) : mêmes couleurs, rayons et rythme que style.css. */
[hidden] { display: none !important; }
.page-large { max-width: 1480px; }

/* ---------- Barre d'outils, puces ---------- */
.liste-outils { margin-bottom: 12px; }
.liste-outils .search { max-width: 520px; }
.liste-outils .switch { white-space: nowrap; }
.select-court select { height: 40px; width: auto; min-width: 220px; border-radius: 10px; }
.show-sm-flex { display: none; }
.court-sm { display: none; }
.liste-table .seul-sm { display: none; }
.liste-puces { margin-bottom: 12px; }
button.filter { font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; }
button.filter:focus-visible { outline: 2px solid var(--brand-2-ink); outline-offset: 2px; }
.filter-alerte span { color: var(--danger); font-weight: 700; }
.filter-alerte:not(.active) { border-color: var(--danger-line); }
.filter-alerte.active { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }
.liste-contexte { align-items: center; }
.liste-contexte .filter .icon { width: 14px; height: 14px; }

/* ---------- Table : dense, en-têtes qui trient ---------- */
.liste-table td { padding: 9px 10px; }
.liste-table th { padding: 0; }
.liste-table th:not(:has(> button)) { padding: 9px 10px; }
.liste-table td:first-child, .liste-table th:first-child:not(:has(> button)) { padding-left: 16px; }
.th-tri {
  display: flex; align-items: center; gap: 4px; width: 100%; min-height: 36px; padding: 9px 10px;
  background: none; border: 0; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; white-space: nowrap;
}
th:first-child > .th-tri { padding-left: 16px; }
.num > .th-tri { justify-content: flex-end; text-align: right; }
.th-tri:hover { color: var(--ink); background: var(--hover); }
.th-tri:focus-visible { outline: 2px solid var(--brand-2-ink); outline-offset: -2px; }
.tri-icone { width: 14px; height: 14px; opacity: 0; transition: opacity .12s; }
.th-tri:hover .tri-icone, .th-tri:focus-visible .tri-icone { opacity: .45; }
th[aria-sort] { color: var(--accent-ink); }
th[aria-sort] .tri-icone { opacity: 1; }
th[aria-sort="ascending"] .tri-icone path:last-child, th[aria-sort="descending"] .tri-icone path:first-child { opacity: 0; }
.liste-table tbody tr:hover td { background: #f6f7fa; }
.liste-table tr.is-late td { background: #fdf6f5; }
.liste-table tr.is-late:hover td { background: #fbefed; }
.liste .table-wrap:focus-visible { outline: 2px solid var(--brand-2-ink); outline-offset: -2px; }
.liste.is-loading tbody { opacity: .55; transition: opacity .15s .1s; }
.liste-squelette .skel-line { display: block; height: 12px; width: 70%; }
.liste-vide td { padding: 8px 16px; }
.liste-vide .empty { padding: 28px 12px; }
.liste-vide-actions { justify-content: center; }

.code { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; letter-spacing: .01em; }
.du { color: var(--danger); font-weight: 650; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.liste-table time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.liste-table .clip { max-width: 220px; }
.liste-table .col-nom .clip { max-width: 260px; display: inline-block; vertical-align: middle; }
.liste-table .col-nom .badge { margin-left: 6px; }
.liste-table .col-ville .clip, .liste-table .col-famille .clip, .liste-table .col-contact .clip { max-width: 170px; }
.liste-table .col-numero { white-space: nowrap; }

/* ---------- Pied : nombre, sommes, pages ---------- */
.liste-pied {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  padding: 8px 12px 8px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px;
}
.liste-compte { font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 2px; }
.pager .icon-btn { width: 36px; height: 36px; }
.pager .icon-btn .icon { width: 18px; height: 18px; }
.pager-pos { padding: 0 8px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.par-page { margin-left: 8px; }
.par-page select { height: 32px; width: auto; padding-left: 10px; font-size: 13px; border-radius: 8px; }

/* ---------- Ventes : onglets ---------- */
.pipe-sep { width: 12px; flex-shrink: 0; }
.pipe-du .pipe-amount { color: var(--danger); font-weight: 600; }
.pipe-du:not(.active) { border-color: var(--danger-line); }
.pipe-note { margin: -8px 0 16px; }
.tabs .count { margin-left: 6px; }

/* ---------- Fiche client ---------- */
.fc-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.fc-kpis .kpi-du { border-color: var(--danger-line); }
.fc-kpis .kpi-label .icon { width: 14px; height: 14px; vertical-align: -2px; }
.fc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 16px; align-items: start; }
.fc-main, .fc-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fc-alerte { border-color: var(--danger-line); }
.fc-lignes { list-style: none; margin: 0; padding: 0; }
.fc-lignes > li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.fc-lignes > li:first-child { border-top: 0; padding-top: 0; }
.fc-lignes + .fc-lignes > li:first-child { border-top: 1px solid var(--line); padding-top: 10px; }
.fc-relances .tl-relance { margin-top: 0; }
.fc-lignes .clip { display: block; }
.fc-types { padding: 0 20px 12px; margin: 0; }
.fc-pieces .table-wrap { border-top: 1px solid var(--line); }
.fc-plus { margin-top: 8px; }
.fc-coord { grid-template-columns: minmax(0, 1fr); }
.contacts > li.is-off { opacity: .6; }

/* ---------- Recherche globale ---------- */
.nav-search { position: relative; margin: 0 4px 12px; }
.nav-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.nav-search input { height: 36px; padding-left: 34px; border-radius: var(--pill); background: var(--surface); font-size: 14px; }
.nav-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; font: 11px/16px var(--font); color: var(--muted); pointer-events: none; }
.nav-search input:focus + kbd, .nav-search input:not(:placeholder-shown) + kbd { display: none; }
.nav-search-btn { display: none; }
.rech-groupes { display: grid; gap: 16px; }
.rech-groupe .card-head { margin-bottom: 0; }
.rech-liste { list-style: none; margin: 0; padding: 0; }
.rech-liste > li > a { display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr) auto; align-items: center; gap: 4px 16px; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--ink); }
.rech-liste > li > a:hover { background: #f6f7fa; text-decoration: none; }
.rech-liste .clip { display: block; }
.rech-champ { display: block; max-width: 640px; margin-bottom: 20px; }
.rech-champ input { height: 44px; font-size: 16px; }

/* ---------- Stock : onglets ---------- */
.stock-onglets { margin-bottom: 16px; }
.qte-neg { color: var(--danger); font-weight: 650; }

@media (max-width: 1600px) { .hide-md { display: none; } }
@media (max-width: 1100px) {
  .fc-grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 320px); }
}
/* Téléphone : une colonne, dans l'ordre d'importance (à encaisser, pièces, contacts, échanges, coordonnées, documents). */
@media (max-width: 760px) {
  .show-sm-flex { display: inline-flex; }
  .court-sm { display: inline; }
  .liste-table .seul-sm { display: table-cell; }
  .liste-outils { gap: 8px; }
  .liste-outils .search { flex-basis: 100%; max-width: none; }
  .tri-sm .icon { width: 16px; height: 16px; color: var(--muted); }
  .tri-sm select { height: 36px; width: auto; max-width: 190px; font-size: 14px; }
  .select-court, .select-court select { width: 100%; min-width: 0; }
  .liste-puces { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .liste-puces::-webkit-scrollbar { display: none; }
  .liste-puces .filter { flex-shrink: 0; height: 34px; }
  .liste-table td { padding: 10px 8px; }
  .liste-table td:first-child { padding-left: 12px; }
  .liste-table th:first-child > .th-tri { padding-left: 12px; }
  .th-tri { padding: 8px; }
  .liste-table td:last-child, .liste-table th:last-child > .th-tri { padding-right: 12px; }
  .liste-table .col-numero, .liste-table .col-nom { white-space: normal; }
  .liste-table .cell-sub.show-sm { display: block; max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .liste-table .col-nom .clip { max-width: 200px; }
  .liste-pied { padding: 8px 12px; }
  .pager .icon-btn[data-page="1"], .pager .icon-btn[aria-label="Dernière page"] { display: none; }
  .par-page { display: none; }
  .pipe-note { display: none; }
  .pipeline { margin-inline: -16px; padding-inline: 16px; gap: 6px; }
  .pipe { flex: 0 0 auto; min-width: 0; padding: 8px 12px; grid-template-columns: auto auto; align-items: baseline; column-gap: 8px; }
  .pipe-head { white-space: nowrap; font-size: 13px; }
  .pipe-count { font-size: 17px; }
  .pipe-amount, .pipe-arrow, .pipe-sep { display: none; }
  /* Fiche client : les trois chiffres sur une ligne, pour que « À encaisser et relances » arrive tout de suite. */
  .fc-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
  .fc-kpis .kpi { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
  .fc-kpis .kpi-label { font-size: 11.5px; line-height: 1.3; }
  .fc-kpis .kpi-label .icon { display: none; }
  .fc-kpis .kpi-value, .fc-kpis .kpi-value.kpi-small { font-size: 15px; text-align: left; grid-row: auto; white-space: nowrap; }
  .fc-kpis .kpi-note, .fc-kpis .bars { display: none; }
  .stock-sum-total { flex-wrap: wrap; row-gap: 6px; }
  .fc-grid { display: flex; flex-direction: column; align-items: stretch; }
  .fc-grid > * , .fc-main > *, .fc-side > * { min-width: 0; }
  .fc-main, .fc-side { display: contents; }
  .fc-lignes > li { grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; }
  .fc-types { padding: 0 16px 12px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .fc-types .filter { flex-shrink: 0; }
  .nav-search { display: none; }
  /* Recherche globale sur téléphone : un bouton en haut à droite de la page, qui défile avec elle (rien ne cache les montants). */
  .layout { position: relative; }
  .nav-search-btn {
    display: inline-grid; place-items: center; position: absolute; z-index: 5; top: 12px; right: 12px;
    width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--ink-2); border: 1px solid var(--line-strong);
  }
  .page-head > :first-child { padding-right: 48px; }
  .hero > div:first-of-type, .hero > :first-child:not(.hero-icon) { padding-right: 48px; }
  .nav-search-btn .icon { width: 20px; height: 20px; }
  .rech-liste > li > a { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 16px; }
  .rech-liste .rech-code { grid-column: 1 / -1; }
}
@media print { .nav-search, .nav-search-btn { display: none !important; } }
/* Un nom très long (ou une recherche sans espace) passe à la ligne au lieu d'élargir la page. */
.page-head h1, .title-row h1, .hero h1, .rech-liste, .page-head .sub, .empty p { overflow-wrap: anywhere; min-width: 0; }
.contact-actions { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; }

/* ---------- Nouvelle pièce : choix du client ---------- */
.choix-client { position: relative; }
.choix-client > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.choix-liste {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-height: 320px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.choix-liste li { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.choix-liste li[aria-selected="true"], .choix-liste li:hover { background: var(--accent-soft); }
.choix-liste .choix-vide { display: block; color: var(--muted); cursor: default; font-size: 13px; }
.choix-liste .choix-vide:hover { background: none; }
.client-card .code { display: block; margin-top: 2px; }

/* ---------- Pièce : sur téléphone, ce qui reste à payer passe avant les lignes ---------- */
@media (max-width: 1040px) {
  .doc-grid:has(.pay-du) { display: flex; flex-direction: column; align-items: stretch; }
  .doc-grid:has(.pay-du) > * { min-width: 0; }
  .doc-grid:has(.pay-du) .doc-side { order: -1; }
}
@media (max-width: 760px) {
  .choix-liste li { grid-template-columns: 64px minmax(0, 1fr); }
  .choix-liste li .small { display: none; }
}
