* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 0;
    color: #1a1a1a;
    background: #f5f5f7;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

[v-cloak] { display: none !important; }

/* === Page de login === */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: #185fa5;
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
}

.login-header h1 {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 600;
}

.subtitle {
    margin: 0;
    color: #6b7280;
    font-size: 13px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 13px;
    color: #4b5563;
    font-weight: 500;
}

.field input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

.field input:focus {
    outline: none;
    border-color: #185fa5;
    box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.15);
}

.field input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

/* === Boutons === */

.btn-primary {
    height: 42px;
    background: #185fa5;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0 16px;
}

.btn-primary:hover:not(:disabled) {
    background: #0f4a85;
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-secondary {
    height: 36px;
    padding: 0 14px;
    background: white;
    color: #4b5563;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-small {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid #fecaca;
    margin-bottom: 16px;
}

/* === Loading screen === */

.loading-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.loading-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.loading-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
}

.loading-message {
    margin: 0 0 20px;
    color: #6b7280;
    font-size: 13px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #185fa5;
    transition: width 0.3s ease;
}

/* === Layout app === */
/* MODIF : height 100vh + overflow hidden pour le scroll interne du tableau */

.app-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo-small {
    width: 28px;
    height: 28px;
    background: #185fa5;
    color: white;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.app-title {
    font-weight: 600;
    font-size: 15px;
}

.main-nav {
    display: flex;
    gap: 16px;
}

.nav-item {
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    padding: 4px 0;
}

.nav-item.active {
    color: #1a1a1a;
    font-weight: 500;
    border-bottom: 2px solid #185fa5;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 13px;
    color: #4b5563;
}

/* MODIF : min-height 0 + overflow hidden pour permettre le scroll interne */
.main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 0;
    overflow: hidden;
}

/* === Sidebar === */
/* MODIF : overflow-y auto + min-height 0 pour scroll indépendant */

.sidebar {
    background: white;
    border-right: 1px solid #e5e7eb;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    min-height: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    margin-bottom: 2px;
}

.filter-group select,
.filter-group input[type="text"] {
    height: 32px;
    padding: 0 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    margin-top: 2px;
}

.checkbox-row input {
    width: 14px;
    height: 14px;
    margin: 0;
}

/* === Zone principale === */
/* MODIF : flex colonne + overflow hidden + min-height 0 */

.content {
    padding: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;   /* AJOUT pour l'overlay */
}

.empty-state {
    color: #6b7280;
    font-size: 14px;
    padding: 40px;
    text-align: center;
}

/* NOUVEAU : conteneur résultat en flex colonne pour pousser le tableau en pleine hauteur */
.result-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.result-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.result-meta {
    font-size: 13px;
    color: #6b7280;
}

/* === Tableau === */
/* MODIF : flex 1 + overflow auto + min-height 0 → le scroll se fait ICI */

.result-table-wrapper {
    flex: 1;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: auto;
    min-height: 0;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.result-table thead {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.result-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 500;
    color: #4b5563;
    white-space: nowrap;
}

.result-table th.num,
.result-table td.num {
    text-align: right;
}

.result-table tbody tr {
    border-bottom: 1px solid #f3f4f6;
}

.result-table tbody tr:hover {
    background: #f9fafb;
}

.result-table td {
    padding: 8px 12px;
    white-space: nowrap;
}

.show-more {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.required {
    color: #dc2626;
    font-weight: 700;
}

/* === Tableau Evolution === */

.eans {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    color: #6b7280;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.evo-positive {
    color: #047857;
    font-weight: 500;
}

.evo-negative {
    color: #b91c1c;
    font-weight: 500;
}

/* === Sticky : en-tête figé en haut, colonne libellé figée à gauche === */

.sticky-left {
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* En-tête (thead) figé en haut lors du scroll vertical */
.result-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f9fafb;
}

/* Coin haut-gauche : sticky sur les deux axes */
.result-table thead .sticky-left {
    background: #f9fafb;
    z-index: 4;
}

/* === Ligne TOTAL (tfoot) figée en bas lors du scroll vertical === */

.total-row {
    background: #f3f4f6;
}

.result-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 3;
    background: #f3f4f6;
    border-top: 2px solid #d1d5db;
    padding: 12px;
    font-size: 13px;
}

.result-table tfoot .sticky-left {
    z-index: 4;
    background: #f3f4f6;
}

/* === Debug box === */

.debug-box {
    margin-top: 20px;
    padding: 10px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 11px;
    color: #4b5563;
}

.debug-box summary {
    cursor: pointer;
    font-weight: 500;
    padding: 4px 0;
}

.debug-box p {
    margin: 6px 0;
}

.debug-box pre {
    background: white;
    padding: 6px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 10px;
    margin: 4px 0;
    max-height: 200px;
    overflow-y: auto;
}

/* === Tri des colonnes === */

.result-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.result-table th.sortable:hover {
    background: #f3f4f6;
}

.sort-arrow {
    display: inline-block;
    margin-left: 4px;
    color: #185fa5;
    font-size: 10px;
    min-width: 10px;
}

/* === Champ de recherche dans la zone tableau === */

.search-box {
    position: relative;
    width: 320px;
}

.search-box input {
    width: 100%;
    height: 36px;
    padding: 0 30px 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
}

.search-box input:focus {
    outline: none;
    border-color: #185fa5;
    box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.15);
}

.btn-clear-search {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #e5e7eb;
    color: #6b7280;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.btn-clear-search:hover {
    background: #d1d5db;
}

/* === Autocomplete famille / labo === */

.autocomplete-group {
    position: relative;
}

.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-top: 2px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    gap: 8px;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f3f4f6;
}

.autocomplete-hint {
    padding: 6px 10px;
    font-size: 11px;
    color: #6b7280;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-style: italic;
}

.famille-code {
    font-family: 'Menlo', 'Consolas', monospace;
    font-weight: 600;
    color: #185fa5;
    font-size: 12px;
    min-width: 50px;
}

.famille-libelle {
    color: #1a1a1a;
}

.selected-famille {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 13px;
}

.btn-clear {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.btn-clear:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* === Radio buttons === */

.radio-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    margin-top: 2px;
}

.radio-row input {
    width: 14px;
    height: 14px;
    margin: 0;
}

/* === Mode hiérarchique === */

.group-row {
    background: #eff6ff;
    cursor: pointer;
    border-top: 1px solid #bfdbfe;
    border-bottom: 1px solid #bfdbfe;
}

.group-row:hover {
    background: #dbeafe;
}

.group-row td {
    padding: 10px 12px;
}

.group-row .sticky-left {
    background: #eff6ff;
}

.group-row:hover .sticky-left {
    background: #dbeafe;
}

.expand-icon {
    display: inline-block;
    width: 14px;
    margin-right: 6px;
    color: #185fa5;
    font-size: 11px;
}

.group-count {
    margin-left: 8px;
    color: #6b7280;
    font-size: 12px;
    font-weight: normal;
}

.product-row .indented {
    padding-left: 32px;
}

/* === Chip de sélection (réutilisable labo/famille) === */

.selected-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 13px;
}

.chip-libelle {
    flex: 1;
    color: #1a1a1a;
}
/* === Toggle nom catalogue / référentiel === */

.toggle-group {
    display: flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.toggle-btn {
    flex: 1;
    height: 32px;
    border: none;
    background: white;
    color: #4b5563;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0 8px;
}

.toggle-btn:first-child {
    border-right: 1px solid #d1d5db;
}

.toggle-btn:hover {
    background: #f3f4f6;
}

.toggle-btn.active {
    background: #185fa5;
    color: white;
}
/* === Burger toggle sidebar === */

.burger-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: #4b5563;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    border-radius: 6px;
    height: 36px;
}

.burger-btn:hover {
    background: #f3f4f6;
}

/* Transition douce de la grille */
.main-layout {
    transition: grid-template-columns 0.2s ease;
}

/* Sidebar masquée : la grille passe à une seule colonne */
.main-layout.sidebar-hidden {
    grid-template-columns: 0 1fr;
}

.main-layout.sidebar-hidden .sidebar {
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    padding-left: 0;
    padding-right: 0;
    border-right: none;
}

/* === Loading overlay + spinner === */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 50;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #185fa5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay-text {
    font-size: 13px;
    color: #4b5563;
}

/* Bandeau discret de rechargement (ventes) */
.reload-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 13px;
    color: #185fa5;
    margin-bottom: 12px;
    flex-shrink: 0;
}
/* ============================================================
   === Onglet Trade ===
   ============================================================ */

/* Zone scrollable : offres empilées + graphique en bas */
.trade-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}

.trade-offer {
    flex: 0 0 auto;          /* ne pas se laisser écraser par le conteneur flex (sinon lignes vides) */
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

/* --- Bandeau offre compact (une ligne) --- */
.offer-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    cursor: pointer;
    border-left: 4px solid transparent;
    transition: background 0.15s;
}

.offer-banner.sell-in {
    background: #eff6ff;
    border-left-color: #185fa5;
}

.offer-banner.sell-out {
    background: #f3f4f6;
    border-left-color: #9ca3af;
}

/* Inconnu / Inutile : bandeau neutre, sans badge (géré côté template) */
.offer-banner.unknown,
.offer-banner.useless {
    background: white;
    border-left-color: #e5e7eb;
}

.offer-banner:hover { filter: brightness(0.98); }

.offer-banner.selected {
    box-shadow: inset 0 0 0 2px #185fa5;
}

.type-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: none;
    display: inline-block;
}
.dot-in  { background: #185fa5; }
.dot-out { background: #9ca3af; }

.offer-title {
    font-size: 13px;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.offer-chip {
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 1px 9px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.offer-count {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
}

.offer-dates {
    font-size: 12px;
    color: #4b5563;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.offer-stats {
    margin-left: auto;
    display: flex;
    gap: 12px;
    align-items: baseline;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.offer-stats .ostat { font-size: 13px; }
.offer-stats .ostat.muted { color: #6b7280; font-size: 12px; }

/* --- Tableau produits d'une offre (hauteur naturelle, scroll global) --- */
.offer-table {
    flex: none;
    max-height: none;
    border: none;
    border-top: 1px solid #e5e7eb;
    border-radius: 0;
    overflow: visible;
}

.product-row { cursor: pointer; }

.product-row.selected,
.product-row.selected .sticky-left {
    background: #fef3c7;   /* ambre clair pour la ligne au graphique */
}

.product-row.unknown td {
    color: #9ca3af;
    font-style: italic;
}

/* --- Graphique 24 mois --- */
.trade-chart-box {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    flex: none;
}

.chart-hint {
    color: #6b7280;
    font-size: 13px;
    text-align: center;
    padding: 24px;
}

.chart-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 12px;
}

.legend-item { display: flex; align-items: center; gap: 6px; }

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

.sw-covered { background: #ea7317; }
.sw-normal  { background: #94a3b8; }

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
}

.bar-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bar-track {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: flex-end;
}

.bar-fill {
    width: 100%;
    border-radius: 3px 3px 0 0;
    min-height: 1px;
    transition: height 0.2s ease;
}

.bar-covered { background: #ea7317; }
.bar-normal  { background: #94a3b8; }

.bar-col:hover .bar-fill { filter: brightness(0.9); }

.bar-label {
    font-size: 9px;
    color: #6b7280;
    margin-top: 4px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* === Contrôles déplier/replier (tous onglets hiérarchiques) === */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tree-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* (anciens styles offer-stats/ostat et résumé KPI retirés : remplacés par le
   bandeau compact et le ruban de résumé) */

/* Tag du plan d'origine sur l'offre (multi-plans) */
.offer-plan-tag {
    font-size: 11px;
    color: #6b7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* Autocomplete : élément surligné (clavier ou survol) */
.autocomplete-item.ac-active {
    background: #dbeafe;
    box-shadow: inset 2px 0 0 #185fa5;
}

/* Le graphique épinglé : séparation visuelle de la liste qui scrolle au-dessus */
.trade-chart-box {
    margin-top: 12px;
}

/* Entête du panneau graphique (titre + bouton masquer) */
.chart-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.chart-panel-title {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* ====================================================================
   Trade v2 : multi-select plans, modes hiérarchique/tableau, split graphe
   ==================================================================== */

/* En-tête : titre + ruban résumé compact */
.trade-head-left { min-width: 0; }
.trade-summary-strip {
    font-size: 13px;
    color: #374151;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}
.trade-summary-strip .sep { color: #d1d5db; }
.info-dot { cursor: help; color: #9ca3af; font-size: 12px; }

/* Bascule de mode (segmented control) */
.mode-toggle {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}
.mode-toggle button {
    border: none;
    background: white;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
}
.mode-toggle button + button { border-left: 1px solid #d1d5db; }
.mode-toggle button.active { background: #185fa5; color: white; }

/* Multi-sélection des plans */
.plan-multi {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 8px;
    max-height: 200px;
    overflow-y: auto;
}
.plan-multi-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 12px;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #f0f0f0;
}
.plan-multi-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-size: 13px;
    cursor: pointer;
}
.plan-multi-item input { cursor: pointer; }
.plan-multi-empty { font-size: 12px; color: #9ca3af; padding: 4px; }
.btn-link {
    background: none;
    border: none;
    color: #185fa5;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }

/* Split : liste à gauche, graphe à droite */
.trade-split {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 16px;
}
.trade-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
/* En mode hiérarchique : la liste d'offres scrolle dans sa propre zone */
.trade-list-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
}
.trade-list-scroll > .trade-offer { margin-bottom: 10px; }
.trade-side {
    flex: 0 0 38%;
    max-width: 520px;
    min-width: 320px;
    overflow-y: auto;
    border-left: 1px solid #e5e7eb;
    padding-left: 16px;
}
.trade-side .bar-chart { overflow-x: auto; }

/* Mode tableau à plat */
.flat-table { border: 1px solid #e5e7eb; border-radius: 8px; }
.flat-table .result-table th,
.flat-table .result-table td { padding: 5px 8px; font-size: 12px; }
.flat-table .sticky-left { max-width: 200px; }
.flat-table .eans { max-width: 110px; }
.col-plan   { white-space: nowrap; color: #4b5563; font-variant-numeric: tabular-nums; }
.col-type   { text-align: center; width: 36px; }
.col-offre  { white-space: nowrap; }
.col-period { white-space: nowrap; color: #4b5563; font-variant-numeric: tabular-nums; }
.flat-table .result-table tfoot td { padding: 8px; font-size: 12px; }
.result-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.result-table th.sortable:hover { background: #eef2f7; }

/* Empilement vertical sur écrans étroits */
@media (max-width: 1100px) {
    .trade-split { flex-direction: column; }
    .trade-side {
        flex: 0 0 auto;
        max-width: none;
        min-width: 0;
        border-left: none;
        border-top: 1px solid #e5e7eb;
        padding-left: 0;
        padding-top: 12px;
    }
}

/* ====================================================================
   Onglet Admin
   ==================================================================== */
.admin-layout {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 24px;
    background: #f3f4f6;
}
.admin-main { max-width: 1000px; margin: 0 auto; }
.admin-section h2 { margin: 0 0 4px; font-size: 20px; color: #1a1a1a; }
.admin-hint { color: #6b7280; font-size: 13px; margin: 0 0 16px; }

.admin-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 18px;
}

.admin-upload-row { display: flex; align-items: center; gap: 12px; }
.btn-file { cursor: pointer; display: inline-flex; align-items: center; }
.admin-filename { font-size: 13px; color: #374151; }

.admin-preview { margin-top: 16px; border-top: 1px solid #f0f0f0; padding-top: 16px; }
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.preview-grid > div { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pv-lbl { display: block; font-size: 11px; font-weight: 500; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.04em; }
.preview-errors { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #991b1b; margin-bottom: 10px; }
.preview-errors ul, .preview-warnings ul { margin: 6px 0 0; padding-left: 18px; }
.preview-warnings { font-size: 12px; color: #92744a; }

.admin-import-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.admin-titre-input, .admin-edit-input {
    flex: 1; min-width: 240px;
    height: 38px; padding: 0 12px;
    border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px;
}
.admin-edit-input { height: 30px; min-width: 180px; }
.admin-replace-note { font-size: 12px; color: #c2410c; }
.admin-success { margin-top: 14px; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 10px 14px; border-radius: 8px; font-size: 13px; }

.admin-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.admin-list-head h3 { margin: 0; font-size: 15px; }
.admin-table { width: 100%; }
.admin-actions { white-space: nowrap; text-align: right; }
.admin-actions .btn-link { margin-left: 10px; }
.btn-link.danger { color: #b91c1c; }
/* === Onglet Top : treeview segmentation === */

.top-seg-tree {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.seg-row {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
    border-bottom: 1px solid #f9fafb;
}

.seg-row:hover { background: #f9fafb; }

.seg-row-l2 { padding-left: 16px; }
.seg-row-l3 { padding-left: 28px; cursor: default; }

.seg-toggle {
    width: 14px;
    flex-shrink: 0;
    font-size: 9px;
    color: #9ca3af;
    text-align: center;
}

.seg-row input[type="checkbox"] {
    width: 13px;
    height: 13px;
    margin: 0 5px 0 2px;
    flex-shrink: 0;
    accent-color: #185fa5;
    cursor: pointer;
}

.seg-lbl {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seg-children {
    border-left: 2px solid #e5e7eb;
    margin-left: 16px;
}

.seg-selection-count {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
    font-style: italic;
}

/* === Onglet Top : attributs / terrains === */

.top-attr-scroll {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 4px;
}

.top-attr-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    font-weight: 600;
    padding: 5px 8px 3px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    gap: 5px;
}

.top-attr-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 99px;
}

.top-badge-attr {
    background: #dbeafe;
    color: #1e40af;
}

.top-badge-terrain {
    background: #ede9fe;
    color: #5b21b6;
}

.top-attr-sep {
    height: 1px;
    background: #e5e7eb;
}


/* === Admin : section Cache === */

.admin-badge {
    font-size: 11px;
    font-weight: 400;
    background: #e5e7eb;
    color: #4b5563;
    padding: 2px 8px;
    border-radius: 99px;
    margin-left: 8px;
    vertical-align: middle;
}

.admin-action-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.admin-success-inline {
    font-size: 13px;
    color: #047857;
    font-weight: 500;
}

.admin-cache-status {
    display: flex;
    gap: 24px;
    margin: 10px 0 4px;
    flex-wrap: wrap;
}

.admin-cache-status > div {
    font-size: 13px;
    color: #374151;
}

.btn-danger {
    height: 36px;
    padding: 0 16px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.btn-danger:hover { background: #b91c1c; }
.btn-danger:disabled { background: #fca5a5; cursor: not-allowed; }


/* === Onglet Pharmascience === */
.pharma-actions {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

/* === Bouton téléchargement catalogue === */
.btn-download {
    display: block;
    margin-top: 6px;
    text-align: center;
    text-decoration: none;
    font-size: 12px;
}

/* ============================================================
   Fiche produit — popup global
   ============================================================ */

.product-card-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.55) !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 24px;
}

.product-card {
    background: #ffffff;
    border-radius: 14px;
    border: 0.5px solid rgba(0,0,0,0.10);
    width: 620px;
    max-width: calc(100vw - 48px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

.pc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 0.5px solid rgba(0,0,0,0.10);
    flex-shrink: 0;
    background: #f9fafb;
}

.pc-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #E6F1FB;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    color: #185fa5;
}

.pc-title-block {
    flex: 1;
    min-width: 0;
}

.pc-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a1a1a;
}

.pc-subtitle {
    font-size: 11px;
    color: #6b7280;
    margin-top: 1px;
}

.pc-uid {
    font-size: 11px;
    color: #6b7280;
    background: #ffffff;
    border: 0.5px solid rgba(0,0,0,0.18);
    border-radius: 5px;
    padding: 2px 7px;
    font-family: monospace;
    white-space: nowrap;
    flex-shrink: 0;
}

.pc-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: 20px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    flex-shrink: 0;
    transition: background .15s;
}
.pc-close:hover { background: #f9fafb; }

.pc-body {
    overflow-y: auto;
    flex: 1;
    padding: 18px;
}

.pc-section {
    margin-bottom: 16px;
}

.pc-section-title {
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pc-section-title::after {
    content: '';
    flex: 1;
    height: 0.5px;
    background: rgba(0,0,0,0.10);
}

.pc-ean-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pc-ean-pill {
    font-size: 12px;
    font-family: monospace;
    background: #f9fafb;
    border: 0.5px solid rgba(0,0,0,0.10);
    border-radius: 5px;
    padding: 3px 8px;
    cursor: pointer;
    color: #1a1a1a;
    transition: border-color .15s, background .15s;
}
.pc-ean-pill:hover {
    border-color: #185fa5;
    background: #E6F1FB;
    color: #0C447C;
}
.pc-ean-pill.active {
    border-color: #185fa5;
    background: #185fa5;
    color: white;
}

.pc-kv {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 6px 12px;
    font-size: 13px;
    align-items: start;
}

.pc-kv-label {
    color: #6b7280;
    padding-top: 1px;
}

.pc-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    line-height: 1.5;
}

.pc-breadcrumb-item { color: #6b7280; }
.pc-breadcrumb-item.leaf { color: #1a1a1a; font-weight: 500; }
.pc-breadcrumb-sep { color: rgba(0,0,0,0.18); font-size: 10px; }

.pc-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.pc-badge {
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 99px;
    font-weight: 400;
}
.pc-badge-attr    { background: #EEEDFE; color: #3C3489; }
.pc-badge-terrain { background: #E1F5EE; color: #085041; }
.pc-badge-flag    { background: #E6F1FB; color: #0C447C; }

/* Prix */
.pc-prix-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
    padding: 8px 0;
}

.pc-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0,0,0,0.18);
    border-top-color: #185fa5;
    border-radius: 50%;
    animation: pc-spin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes pc-spin { to { transform: rotate(360deg); } }

.pc-prix-header {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 14px;
    border: 0.5px solid rgba(0,0,0,0.10);
    border-radius: 10px;
    overflow: hidden;
}

.pc-prix-bloc {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    gap: 3px;
    border-right: 0.5px solid rgba(0,0,0,0.10);
}
.pc-prix-bloc:last-child { border-right: none; }

.pc-prix-value {
    font-size: 20px;
    font-weight: 500;
    color: #1a1a1a;
}

.pc-prix-label {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
}

.pc-penet-value {
    font-size: 18px;
    font-weight: 500;
    color: #3B6D11;
}

.pc-prix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.pc-prix-table td {
    padding: 5px 8px;
    border-bottom: 0.5px solid rgba(0,0,0,0.10);
}
.pc-prix-table td:last-child { text-align: right; font-weight: 500; }
.pc-prix-table tr:last-child td { border-bottom: none; }

.pc-prix-group-head td {
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 8px 3px;
    border-bottom: none !important;
    background: #f9fafb;
}

.pc-no-prix {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
    padding: 8px 0;
}

/* Libellé produit cliquable */
.product-link {
    cursor: pointer;
    color: inherit;
    transition: color .15s;
}
.product-link:hover { color: #185fa5; text-decoration: underline; }

.ean-link {
    cursor: pointer;
    transition: color .15s;
}
.ean-link:hover { color: #185fa5; }


/* === Fiche produit — ajouts === */

.pc-labo-badge {
    font-size: 10px;
    font-weight: 500;
    background: #f3f4f6;
    color: #4b5563;
    border: 0.5px solid #d1d5db;
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 2px;
}

.pc-path-compact {
    font-size: 12px;
    line-height: 1.5;
    color: #1a1a1a;
    display: block;
}

.pc-path-ancestors {
    color: #9ca3af;
    font-size: 11px;
}

.leaflet-pane { z-index: 400 !important; }
.leaflet-top, .leaflet-bottom { z-index: 500 !important; }
.accueil-search-results { z-index: 1000 !important; }
/* ============================================================
   === Améliorations visuelles v2 ===
   ============================================================ */

/* Header : ombre légère pour le détacher du contenu */
.app-header {
    box-shadow: 0 1px 8px rgba(0,0,0,0.07);
}

/* Nav : hover plus visible */
.nav-item {
    border-radius: 6px;
    padding: 4px 8px;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
    background: #f0f4fa;
    color: #185fa5;
}
.nav-item.active {
    color: #185fa5;
    font-weight: 600;
    background: #e8f0fc;
    border-bottom: 2px solid #185fa5;
    border-radius: 0;
    padding: 4px 0;
}

/* KPI cards : ombre subtile */
.accueil-kpi-card {
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    transition: box-shadow 0.2s;
}
.accueil-kpi-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}

/* Alternance de lignes sur tous les tableaux */
.result-table tbody tr:nth-child(even) {
    background: #f8fafd;
}
.result-table tbody tr:nth-child(even) .sticky-left {
    background: #f8fafd;
}
.result-table tbody tr:hover {
    background: #eef4fd !important;
}
.result-table tbody tr:hover .sticky-left {
    background: #eef4fd !important;
}

/* Ligne total plus distincte */
.result-table tfoot td {
    background: #e8f0fc !important;
    color: #185fa5;
    font-weight: 600;
    border-top: 2px solid #185fa5;
}
.result-table tfoot .sticky-left {
    background: #e8f0fc !important;
}

/* En-têtes de colonnes : couleur légère */
.result-table thead th {
    background: #f0f4fa;
    color: #374151;
}

/* Bouton primaire : légère profondeur */
.btn-primary {
    box-shadow: 0 2px 6px rgba(24,95,165,0.25);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(24,95,165,0.35);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(24,95,165,0.2);
}

/* Sidebar : séparateurs de groupes plus nets */
.filter-group + .filter-group {
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
}

/* Admin cards : ombre légère */
.admin-card {
    box-shadow: 0 1px 6px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

/* Logo : légère ombre */
.logo-small {
    box-shadow: 0 2px 6px rgba(24,95,165,0.3);
}

/* Scrollbar plus discrète sur les zones scrollables */
.sidebar::-webkit-scrollbar,
.result-table-wrapper::-webkit-scrollbar,
.trade-list-scroll::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
.sidebar::-webkit-scrollbar-track,
.result-table-wrapper::-webkit-scrollbar-track,
.trade-list-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb,
.result-table-wrapper::-webkit-scrollbar-thumb,
.trade-list-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 99px;
}
.sidebar::-webkit-scrollbar-thumb:hover,
.result-table-wrapper::-webkit-scrollbar-thumb:hover,
.trade-list-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Group rows dans les tableaux hiérarchiques */
.group-row {
    background: #eef4fd !important;
}
.group-row .sticky-left {
    background: #eef4fd !important;
}
.group-row:hover {
    background: #dbeafe !important;
}
.group-row:hover .sticky-left {
    background: #dbeafe !important;
}

/* === Corrections v2.1 === */

/* Alternance plus visible */
.result-table tbody tr:nth-child(even) {
    background: #edf2fb !important;
}
.result-table tbody tr:nth-child(even) .sticky-left {
    background: #edf2fb !important;
}

/* Préserver les couleurs evo-positive/negative sur toutes les lignes */
.result-table tbody tr .evo-positive,
.result-table tbody tr:nth-child(even) .evo-positive {
    color: #047857 !important;
}
.result-table tbody tr .evo-negative,
.result-table tbody tr:nth-child(even) .evo-negative {
    color: #b91c1c !important;
}

/* === Corrections v2.2 : alternance hiérarchique === */

/* Annuler l'alternance nth-child sur les group-rows */
.result-table tbody tr.group-row:nth-child(even),
.result-table tbody tr.group-row:nth-child(odd) {
    background: #eef4fd !important;
}
.result-table tbody tr.group-row:nth-child(even) .sticky-left,
.result-table tbody tr.group-row:nth-child(odd) .sticky-left {
    background: #eef4fd !important;
}
.result-table tbody tr.group-row:hover,
.result-table tbody tr.group-row:hover .sticky-left {
    background: #dbeafe !important;
}

/* Alternance uniquement sur les product-rows */
.result-table tbody tr.product-row:nth-child(even) {
    background: #edf2fb !important;
}
.result-table tbody tr.product-row:nth-child(even) .sticky-left {
    background: #edf2fb !important;
}
.result-table tbody tr.product-row:nth-child(odd) {
    background: white !important;
}
.result-table tbody tr.product-row:nth-child(odd) .sticky-left {
    background: white !important;
}
.result-table tbody tr.product-row:hover,
.result-table tbody tr.product-row:hover .sticky-left {
    background: #eef4fd !important;
}

/* === Corrections v2.3 : couleurs evo dans tfoot === */
.result-table tfoot td .evo-positive,
.result-table tfoot .evo-positive {
    color: #047857 !important;
}
.result-table tfoot td .evo-negative,
.result-table tfoot .evo-negative {
    color: #b91c1c !important;
}

/* === IMPRESSION ET PDF === */

@media print {

    @page {
        size: A4 landscape;
        margin: 1cm;
    }

    /* Masquer tout sauf la zone ciblee */
    #app > * {
        display: none !important;
    }

    /* L'app-layout contenant la zone active devient visible */
    body[data-print-area] #app > .app-layout {
        display: flex !important;
    }

    /* Masquer sidebar, header, filtres dans la zone imprimee */
    .app-header,
    .sidebar,
    .btn-export,
    .btn-clear-search,
    .search-box,
    .tree-controls,
    .mode-toggle,
    .trade-split > .trade-side,
    .result-meta {
        display: none !important;
    }

    /* Le content et tous ses parents : liberer la hauteur */
    .content,
    .main-layout,
    .app-layout,
    .result-container,
    .result-table-wrapper {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
        flex: none !important;
    }

    /* Masquer tous les result-container sauf celui cible */
    .result-container {
        display: none !important;
    }

    body[data-print-area="print-area-evo"] #print-area-evo,
    body[data-print-area="print-area-cat"] #print-area-cat,
    body[data-print-area="print-area-trade"] #print-area-trade,
    body[data-print-area="print-area-top"] #print-area-top,
    body[data-print-area="print-area-pharma"] #print-area-pharma {
        display: block !important;
    }

    /* Tableau pleine largeur */
    .result-table-wrapper {
        overflow: visible !important;
        width: 100% !important;
    }

    .result-table {
        width: 100% !important;
        font-size: 10px;
        border-collapse: collapse;
    }

    .result-table th,
    .result-table td {
        border: 1px solid #ccc !important;
        padding: 3px 5px !important;
    }

    .result-table thead {
        display: table-header-group;
    }

    .result-table tr {
        page-break-inside: avoid;
    }

    .result-header h2 {
        font-size: 14px;
        margin-bottom: 8px;
    }
}