/*
 * Trouvaille — feuille de style du module d'inventaire du site.
 *
 * Elle complète style.css : on n'y remet ni les couleurs, ni les boutons, ni la barre
 * d'application, qui existent déjà. On ajoute seulement ce que le site n'avait pas :
 * le tableau dense, les pastilles de statut, la règle des trois canaux, les fenêtres
 * de modification, et la bascule en cartes sur téléphone.
 *
 * Toutes les pages du module la chargent : inventaire, tableau de bord, fiche d'objet,
 * vente, entrée de lot, registre, emplacements.
 */

/* ─────────────────────── Grilles et cartes ─────────────────────── */

.grille { display: grid; gap: var(--e3); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-fiche { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); align-items: start; }
@media (max-width: 980px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: minmax(0, 1fr); } .g-fiche { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .g4, .g2 { grid-template-columns: minmax(0, 1fr); } }

.carte { background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--r-l); padding: var(--e3); display: block; text-decoration: none; color: inherit; }
a.carte:hover { border-color: var(--gris); }
.carte-titre { display: flex; align-items: center; gap: var(--e2); margin-bottom: var(--e3); flex-wrap: wrap; }
.carte-titre h2 { margin: 0; font-size: 1.15rem; margin-right: auto; }
.carte-titre h3 { margin: 0; font-size: 1rem; margin-right: auto; }

.intitule { font-size: .82rem; color: var(--gris); display: block; }
.gros { font-size: 1.8rem; font-weight: 600; letter-spacing: -.02em; display: block; line-height: 1.2; }
.detail { font-size: .8rem; color: var(--gris-clair); display: block; }
.num { font-variant-numeric: tabular-nums; }
.separateur { height: 1px; background: var(--bordure); border: 0; margin: var(--e3) 0; }

/* ─────────────────────── Barre d'outils ─────────────────────── */

.barre-outils { display: flex; gap: var(--e2); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--e3); }
.barre-outils .champ { display: flex; flex-direction: column; gap: 2px; }
.barre-outils label { font-size: .76rem; color: var(--gris); }
.barre-outils .recherche { flex: 1 1 240px; min-width: 190px; }
.barre-outils select { width: auto; min-width: 140px; }

/* Le titre d'une page de travail n'est pas le titre d'une page de vente. La règle
   générale du site le dessine à 3,2 rem — juste pour le bandeau d'accueil, où il n'y a
   que lui à lire. Sur un tableau de bord, il écrasait les chiffres qui, eux, comptent. */
.titre-module { display: flex; align-items: flex-end; gap: var(--e3); flex-wrap: wrap; margin-bottom: var(--e3); }
.titre-module h1 { margin: 0; font-size: clamp(1.3rem, 2vw, 1.55rem); line-height: 1.2; letter-spacing: -.01em; }
.titre-module > div > .petit { margin: 3px 0 0; }
.titre-module .actions { margin-left: auto; display: flex; gap: var(--e2); flex-wrap: wrap; }

/* ─────────────────────── Tableau dense ─────────────────────── */

.cadre-tableau { border: 1px solid var(--bordure); border-radius: var(--r-l); background: var(--carte); overflow: auto; max-height: 66vh; }
table.liste { width: 100%; min-width: 900px; border-collapse: collapse; font-size: .9rem; }
table.liste thead th { position: sticky; top: 0; z-index: 2; background: var(--sable); text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--bordure); white-space: nowrap; }
table.liste thead th.triable { cursor: pointer; user-select: none; }
table.liste thead th.triable:hover { color: var(--encre); }
table.liste td { padding: 9px 12px; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
table.liste tbody tr:last-child td { border-bottom: 0; }
table.liste tbody tr:hover { background: var(--ivoire, #fdfaf5); }
table.liste tbody tr.choisie { background: var(--sable, #f5efe4); }
.col-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.miniature { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--sable); display: grid; place-items: center; font-size: .66rem; color: var(--gris-clair); }
.miniature-l { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: var(--r-l); object-fit: cover; }

/* ─────────────────────── Pastilles de statut ─────────────────────── */

/* Une pastille porte toujours son texte : la couleur seule exclut les daltoniens et
   disparaît à l'impression. */
.pastille { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.pastille::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-tri { background: var(--sable); color: var(--encre-2); border-color: var(--bordure); }
.st-estimer { background: var(--sable, #f5efe4); color: #8a6a1f; }
.st-rayon { background: #eef4ef; color: #3f6b4a; }
.st-ligne { background: #eef2f5; color: #35566e; }
.st-reserve { background: var(--sable, #f5efe4); color: #8a6a1f; }
.st-vendu { background: var(--encre); color: var(--ivoire); }
.st-depot { background: #f3eefa; color: #5b4a86; }
.st-casse { background: #fbf0ef; color: #9c3330; }

.positif { color: #3f6b4a; font-weight: 600; }
.negatif { color: #9c3330; font-weight: 600; }
.dort { color: #9c3330; font-weight: 500; }
.modifiable { cursor: pointer; border-bottom: 1px dashed var(--gris-clair); }
.modifiable:hover { color: var(--caramel); border-bottom-color: var(--caramel); }

/* ─────────────────────── Listes en rangées ─────────────────────── */

.rangee { display: flex; align-items: center; gap: var(--e3); padding: var(--e2) 0; border-bottom: 1px solid var(--bordure); }
.rangee:last-child { border-bottom: 0; }
.rangee .corps { flex: 1; min-width: 0; }
.rangee .nom { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rangee .droite { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.jauge { height: 6px; border-radius: 999px; background: var(--sable); overflow: hidden; display: block; }
.jauge > span { display: block; height: 100%; background: var(--caramel); }
.rubans { display: flex; height: 22px; border-radius: 999px; overflow: hidden; border: 1px solid var(--bordure); }
.legende { display: flex; flex-wrap: wrap; gap: var(--e2) var(--e3); margin-top: var(--e2); }
.legende span { font-size: .8rem; color: var(--gris); display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ─────────────────────── La règle des trois canaux ─────────────────────── */

.regle { margin: var(--e4) 0 var(--e5); }
.canal { display: flex; align-items: center; gap: var(--e2); margin-bottom: 6px; }
.canal .etiq { flex: 0 0 96px; font-size: .8rem; color: var(--gris); }
.canal .piste { position: relative; flex: 1; height: 16px; background: var(--sable); border-radius: 999px; }
.canal .bande { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.canal .valeurs { flex: 0 0 116px; text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.repere { position: absolute; top: -7px; bottom: -24px; width: 2px; background: var(--encre); }
.repere span { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: .74rem; font-weight: 600; background: var(--encre); color: var(--ivoire); padding: 1px 7px; border-radius: 999px; }

/* ─────────────────────── Fenêtres, messages, états ─────────────────────── */

.voile { position: fixed; inset: 0; z-index: 50; background: rgba(31,29,26,.45); display: grid; place-items: center; padding: var(--e3); }
.modale { background: var(--carte); border-radius: var(--r-l); border: 1px solid var(--bordure); width: min(560px,100%); max-height: 86vh; overflow: auto; padding: var(--e4); box-shadow: 0 24px 60px rgba(31,29,26,.25); }
.modale h2 { margin-bottom: var(--e3); }
.modale label, .champ label { display: block; font-size: .82rem; color: var(--gris); margin: var(--e2) 0 2px; }

.message { border-radius: var(--r); padding: 10px 14px; font-size: .88rem; margin-bottom: var(--e3); }
.message.erreur { background: #fbf0ef; border: 1px solid #d8bcba; color: #9c3330; }
.message.ok { background: #eef4ef; border: 1px solid #c9dfd0; color: #3f6b4a; }
.message.note { background: var(--sable, #f5efe4); border: 1px solid #e6d5aa; color: var(--encre-2); }

.etat-vide { padding: var(--e4) var(--e3); text-align: center; color: var(--gris); }
.etat-vide h3 { color: var(--encre); margin-bottom: var(--e1); }

.champs-en-ligne { display: flex; gap: var(--e2); flex-wrap: wrap; align-items: flex-end; }
.champs-en-ligne > * { flex: 1 1 160px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--bordure); background: var(--carte); font-size: .76rem; color: var(--gris); white-space: nowrap; }

.barre-masse { position: sticky; bottom: var(--e3); z-index: 15; display: flex; gap: var(--e2); align-items: center; flex-wrap: wrap; margin-top: var(--e3); padding: 10px var(--e3); background: var(--encre); color: var(--ivoire); border-radius: var(--r-l); box-shadow: 0 10px 30px rgba(31,29,26,.18); }
.barre-masse .compteur { font-weight: 600; margin-right: auto; }
.barre-masse .btn-outline { background: transparent; border-color: rgba(253,250,245,.35); color: var(--ivoire); }

/* ─────────────────────── Téléphone ─────────────────────── */

@media (max-width: 720px) {
    .cadre-tableau { border: 0; background: transparent; max-height: none; overflow: visible; }
    table.liste { min-width: 0; }
    table.liste, table.liste tbody, table.liste tr, table.liste td { display: block; width: 100%; }
    table.liste thead { display: none; }
    table.liste tr { background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--r-l); margin-bottom: var(--e2); padding: var(--e2) var(--e3); }
    table.liste td { border: 0; padding: 4px 0; display: flex; gap: var(--e3); align-items: center; }
    table.liste td::before { content: attr(data-intitule); flex: 0 0 42%; font-size: .74rem; text-transform: uppercase; color: var(--gris); }
    table.liste td.sans-intitule::before { content: none; }
    table.liste td.titre { display: block; font-weight: 500; margin-bottom: var(--e1); }
    table.liste td.titre::before { content: none; }
    .barre-masse { position: fixed; left: var(--e3); right: var(--e3); bottom: var(--e3); }
    .canal .etiq { flex: 0 0 74px; }
    .canal .valeurs { flex: 0 0 92px; }
}

/* ─────────────────────── Impression (le registre surtout) ─────────────────────── */

@media print {
    .app-bar, .barre-outils, .barre-masse, .sans-impression, .btn { display: none !important; }
    body { background: #fff; font-size: 11pt; }
    .cadre-tableau { border-color: #999; border-radius: 0; max-height: none; overflow: visible; }
    table.liste { min-width: 0; }
    table.liste thead th { background: #eee; color: #000; }
    table.liste tr { page-break-inside: avoid; }
    .pastille { border: 1px solid #999; background: #fff !important; color: #000 !important; }
}

/* Le résumé chiffré au-dessus d'un tableau (nombre d'objets, valeur, marge). */
.resume { display: flex; gap: var(--e3); align-items: baseline; flex-wrap: wrap; margin-bottom: var(--e2); }
.resume strong { font-size: 1.05rem; }

/* ─────────────────────── Une carte sur laquelle on peut cliquer ───────────────────────
 *
 * Les cartes de zone ÉTAIENT cliquables, mais rien ne le disait : même fond, même bordure,
 * même immobilité qu'une carte de chiffres. On ne clique pas ce qu'on ne croit pas
 * cliquable — les réglages d'une zone n'ont donc jamais été trouvés. La bordure se
 * réchauffe au survol, la carte se soulève, et une mention dit ce qu'on y trouvera.
 */
.carte-cliquable { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
    transition: border-color .12s, transform .12s, box-shadow .12s; }
.carte-cliquable:hover, .carte-cliquable:focus-visible { border-color: var(--caramel);
    transform: translateY(-1px); box-shadow: 0 6px 18px rgba(31,29,26,.07); }
.carte-cliquable .ouvrir { display: block; margin-top: var(--e2); font-size: .78rem;
    color: var(--gris-clair); }
.carte-cliquable:hover .ouvrir { color: var(--caramel); }
.carte-cliquable .ouvrir::after { content: " →"; }
@media (prefers-reduced-motion: reduce) { .carte-cliquable { transition: none; }
    .carte-cliquable:hover { transform: none; } }

/* ─────────────────────── Modale d'aide & Cadre légal compact ─────────────────────── */
.modal-aide-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(31, 29, 26, 0.45);
    backdrop-filter: blur(3px);
    display: grid; place-items: center; padding: 20px;
}
.modal-aide-backdrop[hidden] { display: none; }
.modal-aide-carte {
    background: #fdfaf5; border: 1px solid var(--bordure);
    border-radius: 16px; max-width: 680px; width: 100%;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 50px rgba(31, 29, 26, 0.22);
}
.modal-aide-header {
    padding: 18px 22px; border-bottom: 1px solid var(--bordure);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-aide-header h2 { margin: 0; font-size: 1.15rem; }
.modal-aide-close {
    background: none; border: 0; font-size: 1.25rem; cursor: pointer;
    color: var(--gris); line-height: 1; padding: 4px 8px; border-radius: 6px;
}
.modal-aide-close:hover { background: var(--sable); color: var(--encre); }
.modal-aide-corps {
    padding: 20px 22px; overflow-y: auto; display: grid; gap: var(--e3);
    font-size: .9rem; line-height: 1.5;
}
.modal-aide-footer {
    padding: 14px 22px; border-top: 1px solid var(--bordure);
    display: flex; justify-content: flex-end; background: #fff;
    border-radius: 0 0 16px 16px;
}

/* ─────────────────────── Sélecteur de compartiments métiers (Tableau de bord) ─────────────────────── */
.tb-onglets-secteur {
    display: flex;
    gap: 8px;
    margin-bottom: var(--e4);
    background: var(--carte, #fff);
    border: 1px solid var(--bordure, #e6ddcd);
    border-radius: var(--r-l, 12px);
    padding: 6px;
    overflow-x: auto;
}
.tb-tab {
    flex: 1 1 0;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all .15s ease;
    color: var(--encre, #1f1d1a);
}
.tb-tab:hover {
    background: var(--sable, #f5efe4);
}
.tb-tab-icon {
    font-size: 1.25rem;
    margin-bottom: 4px;
}
.tb-tab-title {
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.2;
}
.tb-tab-sub {
    font-size: .74rem;
    color: var(--gris, #6c6459);
    margin-top: 2px;
}
.tb-tab.actif {
    background: #fff;
    border-color: var(--bordure, #e6ddcd);
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
}
.tb-tab.sec-notariat.actif {
    border-left: 3px solid #8a5a2b;
    background: var(--ivoire, #fdfaf5);
}
.tb-tab.sec-boutique.actif {
    border-left: 3px solid #1b6b55;
    background: #f4faf7;
}
.tb-tab.sec-brocante.actif {
    border-left: 3px solid #a0522d;
    background: var(--ivoire, #fdfaf5);
}

/* ─────────────────────── Barre de filtrage par compartiment de stock (Inventaire) ─────────────────────── */
.filtre-compartiment-bar {
    display: flex;
    gap: 6px;
    margin-bottom: var(--e3);
    overflow-x: auto;
    padding-bottom: 4px;
}
.btn-comp-stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: .82rem;
    font-weight: 500;
    border: 1px solid var(--bordure, #e6ddcd);
    border-radius: 20px;
    background: var(--carte, #fff);
    color: var(--encre, #1f1d1a);
    cursor: pointer;
    white-space: nowrap;
    transition: all .15s ease;
}
.btn-comp-stock:hover {
    background: var(--sable, #f5efe4);
    border-color: var(--gris-clair, #a09889);
}
.btn-comp-stock.actif {
    background: var(--encre, #1f1d1a);
    color: #fff;
    border-color: var(--encre, #1f1d1a);
}
.btn-comp-stock.comp-notariat.actif {
    background: #8a5a2b;
    border-color: #8a5a2b;
}
.btn-comp-stock.comp-boutique.actif {
    background: #1b6b55;
    border-color: #1b6b55;
}
.btn-comp-stock.comp-brocante.actif {
    background: #a0522d;
    border-color: #a0522d;
}
