:root {
    --bg: #f4f6f8;
    --panel: #fff;
    --soft: #f8fafb;
    --text: #17202a;
    --muted: #68727d;
    --border: #dfe4e8;
    --accent: #1687a3;
    --parcel: #f1c40f;
    --transport: #2f80ed;

    /*Uniformisation du hearder pour avoir la même hauteur en input et result*/

    --header-height: 98px;

     /* Couleur Header gauche */

    --arrangor-blue-dark: #0348d7;
    --arrangor-blue-light: #2f80ed;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter,"Segoe UI",Arial,sans-serif
}

button,input,textarea {
    font: inherit
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 18px;
    padding: 18px
}

.input-panel,.result-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 12px 30px rgba(20,31,43,.07)
    
}

.input-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px
}

/*Header de l'input panel*/

.brand {
    margin: -24px -24px 0;
    padding: 14px 24px 13px;

    height: var(--header-height);
    min-height: var(--header-height);

    display: flex;
    flex-direction: column;
    justify-content: center;

    background: linear-gradient(
        180deg,
        var(--arrangor-blue-dark) 0%,
        #145ee6 25%,
        var(--arrangor-blue-light) 75%
    );

    border-radius: 18px 18px 0 0;

    border-bottom: 1px solid rgba(0, 32, 110, .22);
}

.brand h1 {
    margin: 5px 0 6px;
    font-size: 0.85rem;
    color: #ffffff;
}

/*Gestion du positionnement du texte dans le input header 
et de la couleur de la section coller, regrouper, lire etc... */

.brand p {
    margin: 0;
    color: var(--parcel);
    font-size: .75rem
}

.brand .eyebrow {
    color: #ffe36b;
}

.eyebrow {
    color: var(--accent);
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .12em
}

/*Gestion du titre au dessus du champs des données à introduire*/

.field-label {
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom:-7px;
    color: var(--muted)
}

/*Gestion du titre CDU au dessus du menu des résultat après organisation */

.rail-title {
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 16px;
}

#cduList > .rail-title{
    margin-bottom:16px;
}

.raw-input {
    min-height: 300px;
    border: 1px solid #cfd6dc;
    border-radius: 14px;
    padding: 15px;
    resize: vertical
}

.input-actions {
    display: flex;
    gap: 10px
}

.primary-btn,.secondary-btn {
    padding: 11px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-weight: 700;
    cursor: pointer
}

.primary-btn {
    background: var(--text);
    color: #fff;
    flex: 1
}

.secondary-btn {
    background: #fff
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: #fff;
    display: flex;
    flex-direction: column;
    text-align: left
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 800
}

.stat-label {
    font-size: .78rem;
    color: var(--muted)
}

.audit-drawer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    overflow: hidden
}

.audit-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 12px 0;
    display: flex;
    justify-content: space-between;
    font-weight: 750;
    color: var(--muted);
    cursor: pointer
}

.audit-content {
    max-height: 300px;
    overflow: auto;
    background: #eef7ff;
    border-radius: 12px;
    padding: 12px;
    transition: .3s
}

.audit-drawer.collapsed .audit-content {
    max-height: 0;
    padding: 0;
    opacity: 0
}

.audit-meta {
    font-size: .75rem;
    color: var(--muted);
    margin-bottom: 8px
}

.log-entry {
    font-size: .8rem;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border)
}

.result-panel {
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    overflow: hidden
}

.result-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin: -18px -18px 16px;
    padding: 14px 18px 13px;
    background: linear-gradient(180deg,#efc400 0%,#ffd52f 52%,#ffe57b 100%);
    border-radius: 18px 18px 0 0;
    border-bottom: 1px solid rgba(117,93,0,.16);
    min-height: var(--header-height);
    height: var(var(--header-height))
}

.result-toolbar h2 {
    margin: 5px 0 6px;
    font-size: 0.75rem;
    color: var(--arrangor-blue-dark);
}

.result-brand-block {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0
}

.header-wordmark {
    display: block;
    width: clamp(150px,12vw,210px);
    height: auto;
    max-height: 58px;
    object-fit: contain;
    object-position: center;
    flex: 0 0 auto;
}

.result-context {
    padding-left: 18px;
    border-left: 1px solid rgba(23,32,42,.18)
}

.result-context h2 {
    margin: 3px 0 0;
    font-size: 1rem
}

.result-eyebrow {
    color: #173f8f
}

.search-wrap {
    width: min(540px,45%);
    position: relative;
    flex: 0 1 540px
}

.search-wrap input {
    width: 100%;
    border: 1px solid rgba(23,32,42,.2);
    border-radius: 999px;
    padding: 12px 90px 12px 16px;
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(8px)
}

.workspace {
    display: grid;
    grid-template-columns: 245px 1fr;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    min-height: 620px
}

.cdu-rail {
    background: var(--soft);
    border-right: 1px solid var(--border);
    padding: 14px 10px;
    overflow-y: auto
}

.cdu-item {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 11px;
    padding: 11px 10px;
    text-align: left;
    cursor: pointer;
    position: relative
}

.cdu-item.active {
    background: #fff;
    border-color: #cfd6dc
}

.cdu-item:focus{
    outline:none;
}

.cdu-item.active:before {
    content: "";
    position: absolute;
    left: -1px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 999px;
    background: var(--accent)
}

.cdu-item.parcel.active:before {
    background: var(--parcel)
}

.cdu-item.transporteur.active:before {
    background: var(--transport)
}

.cdu-mainline {
    display: flex;
    justify-content: space-between
}

.cdu-number {
    font-weight: 600;
    font-size: .88rem
}

.cdu-subline {
    margin-top: 6px;
    font-size: .68rem;
    color: var(--muted)
}

.detail-pane {
    padding: 24px;
    overflow: auto
}

.detail-content {
    animation: fade .35s ease
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateX(10px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    padding-bottom: 18px
}

.title-copy-row {
    display: flex;
    gap: 8px;
    align-items: center
}

.code-copy-row {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 450;
}

.detail-title {
    margin: 5px 0;
    font-weight: 550
}

.copy-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer
}

.table-wrap {
    margin-top: 18px
}

.data-table {
    width: 100%;
    border-collapse: collapse
}

.data-table th,.data-table td {
    padding: 12px;
    border-bottom: 1px solid #edf0f2;
    text-align: left
}

.code-cell {
    font-weight: 800
}

.multi-badge {
    display: inline-block;
    margin-top: 6px;
    background:var(--arrangor-blue-light); /*#efecfb;*/
    color: var(--panel); /*#6b57b8;*/
    border-radius: 999px;
    padding: 3px 8px;
    font-size: .68rem;
    font-weight: 740
}

.external-link {
    color: var(--accent);
    border: 0;
    background: transparent;
    font-weight: 700;
    cursor: pointer
}

.postal-panel {
    margin-top: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfcfd;
    overflow: hidden
}

.postal-panel.hidden {
    display: none
}

.postal-head {
    display: flex;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border)
}

.postal-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #f7fafc
}

.postal-result {
    padding: 16px 20px 20px
}

.tracking-loading,.tracking-probe,.tracking-empty,.tracking-error,.tracking-warning {
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 12px
}

.tracking-loading {
    background: #f7fafc
}

.tracking-probe {
    background: #fff9dc
}

.tracking-error {
    background: #fff0f0
}

.tracking-warning {
    background: #fff3e6
}

.tracking-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    margin-top: 14px
}

.tracking-card-head {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    background: #fbfcfd;
    border-bottom: 1px solid var(--border)
}

.tracking-badges span {
    display: inline-block;
    margin: 6px 6px 0 0;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef4f8;
    font-size: .68rem;
    font-weight: 800
}

.tracking-state {
    max-width: 320px;
    font-size: .78rem;
    font-weight: 800
}

.tracking-section {
    padding: 14px 16px
}

.tracking-section h5 {
    margin: 0 0 10px;
    color: var(--muted)
}

.trk-step,.trk-event {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    font-size: .8rem
}

.trk-step.active {
    font-weight: 700
}

.empty-state {
    display: grid;
    place-content: center;
    height: 100%;
    color: var(--muted)
}

.empty-state-branded {
    position: relative;
    isolation: isolate;
    text-align: center;
    gap: 12px;
    min-height: 520px
}

.empty-state-branded > span {
    position: relative;
    z-index: 2;

    transform: translateY(100px);
}

.empty-state-branded>span {
    position: relative;
    z-index: 2
}

.empty-logistics-mark {
    position: absolute;
    z-index: 1;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-55%);
    width: min(52%,560px);
    max-height: 72%;
    object-fit: contain;
    opacity: .075;
    filter: saturate(.95);
    pointer-events: none;
    user-select: none
}

.empty-brand-footer {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 2;
    pointer-events: none;
    user-select: none;
    opacity: .065;
    transition: opacity .28s ease,transform .28s ease;
}

.empty-brand-footer img {
    display: block;
    width: clamp(175px,17vw,290px);
    height: auto;
    max-height: 74px;
    object-fit: contain;
    object-position: center;
}

.empty-brand-footer.hidden {
    opacity: 0;
    transform: translate(-50%,10px)
}

@media(max-width:1250px) {
    .result-toolbar {
        gap: 14px
    }

    .header-wordmark {
        width: 160px
    }

    .result-context {
        padding-left: 12px
    }

    .search-wrap {
        width: min(460px,44%)
    }
}

@media(max-width:1050px) {
    .app-shell {
        grid-template-columns: 1fr
    }

    .workspace {
        grid-template-columns: 220px 1fr
    }
}

/*Deplacement ligne info 'apparaitra ici' par la gauche*/

@media (min-width: 1251px) {

    .empty-state-branded > span {
        left: -135px;
    }

}

@media(max-width:720px) {
    .workspace {
        grid-template-columns: 1fr
    }

    .result-toolbar {
        flex-direction: column;
        align-items: stretch;
        min-height: 0
    }

    .result-brand-block {
        justify-content: space-between
    }

    .header-wordmark {
        width: 160px
    }

    .result-context {
        margin-left: auto
    }

    .search-wrap {
        width: 100%;
        flex-basis: auto
    }

    .empty-logistics-mark {
        width: 76%
    }

    .empty-brand-footer img {
        width: 190px
    }
}

/* ===== V7.2 — branding refinements only ===== */ 

.raw-input-wrap {
    position: relative;
    width: 100%;
}

.raw-input-wrap .raw-input {
    position: relative;
    z-index: 2;
    width: 100%;
    display: block;
    background: rgba(255,255,255,.93);
}

.raw-input-watermark {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    width: min(76%,245px);
    max-height: 72%;
    object-fit: contain;
    opacity: .065;
    pointer-events: none;
    user-select: none;
    transition: opacity .22s ease, transform .22s ease;
}

.raw-input-watermark.hidden {
    opacity: 0;
    transform: translate(-50%,-46%);
}

/* The approved wordmark contains a descender on the g:
   give both placements enough vertical breathing room. */ 
   
   .header-wordmark, .empty-brand-footer img {
    padding-top: 2px;
    padding-bottom: 5px;
}

/* The renamed header labels keep exactly the existing hierarchy and position. */ 

.result-context h2 {
    text-transform: none;
}

.detail-section-context {
    margin: 0 0 13px;
}

.detail-section-context h4 {
    margin: 3px 0 0;
    font-size: .92rem;
    font-weight: 600;
    color: var(--text);
}

/* ===== V7.4 — micro-ajustements cosmétiques uniquement ===== */ 

.raw-input-wrap {
    position: relative;
    width: 100%;
}

.raw-input-wrap .raw-input {
    position: relative;
    z-index: 2;
    width: 100%;
    display: block;
    background: rgba(255,255,255,.93);
}

/* Exemple de format : taille volontairement réduite pour rester sur une seule ligne. */ 

.raw-input-hint {
    position: absolute;
    z-index: 4;

    top: 14px;
    left: 15px;
    right: 15px;

    display: flex;
    flex-direction: column;
    gap: 6px;

    pointer-events: none;
    user-select: none;

    transition:
        opacity .18s ease,
        transform .18s ease,
        visibility .18s ease;
}

.raw-input-hint-title {
    color: var(--muted);
    
    font-size: .72rem;
    font-weight: 800;
    
    letter-spacing: .08em;
    text-transform: uppercase;
}

.raw-input-hint-example {
    color: #65717c;

    font-size: .75rem;
    font-weight: 400;
   
    white-space: nowrap;
}

.raw-input-hint.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-2px);
}

/* La trame logistique V7.2 est conservée telle quelle. */ 

.raw-input-watermark {
    position: absolute;
    z-index: 3;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    width: min(76%,245px);
    max-height: 72%;
    object-fit: contain;
    opacity: .065;
    pointer-events: none;
    user-select: none;
    transition: opacity .22s ease,transform .22s ease;
}

.raw-input-watermark.hidden {
    opacity: 0;
    transform: translate(-50%,-46%);
}

/* Le nouveau PNG ne contient que le mot-symbole ; aucune seconde ligne possible. */ 

.header-wordmark, .empty-brand-footer img {
    padding: 0;
    clip-path: none;
}

/* ===== V7.5 — restauration comportementale V5, sans refonte visuelle ===== */ /* KPI "À vérifier" : hover V5 restauré */ 

.stat-button {
    cursor: pointer;
    transition: border-color .16s ease,box-shadow .16s ease;
}

.stat-button:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(22,135,163,.06);
}

/* Journal d'audit : code couleur V5 restauré */ 

.log-entry {
    font-size: .8rem;
    line-height: 1.4;
    padding: 9px 0;
    border-bottom: 1px dashed var(--border);
}

.log-entry:last-child {
    border-bottom: 0;
}

.log-entry strong {
    display: block;
}

.log-entry.warning strong {
    color: #9b6a00;
}

.log-entry.error strong {
    color: #a13b3b;
}

.log-entry span {
    display: block;
    margin-top: 3px;
    color: var(--text);
    font-size: .76rem;
    line-height: 1.38;
}

/* Recherche V5 : compteur + croix explicite + highlight */ 

.search-wrap input {
    padding-right: 120px;
}

.search-count {
    position: absolute;
    right: 42px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: .76rem;
    white-space: nowrap;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #816e6e;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
}

.search-clear:hover {
    background: #fda69b; /*anciennce valeur -> rgba(42, 23, 23, 0.07)*/
    color: var(--text);
}

.search-clear.hidden {
    display: none;
}

/*Masquer la croix de suppression native de edge*/

.search-wrap input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.match-row {
    background: #fffbea;
}

mark {
    background: #ffe56b;
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
}

.detail-search-meta {
    margin-top: 5px;
    color: var(--muted);
    font-size: .78rem;
}

/* Multi-CDU V5 restauré */ 

.multi-note {
    font-size: .73rem;
    color:var(--muted); /*#434249;*/
    margin-top: 4px;
}

.multi-popover {
    margin-top: 8px;
    padding: 10px;
    border: 1px solid #dcd6f4;
    border-radius: 10px;
    background:linear-gradient(180deg,#efc400 0%,#fce89a 55%,#fdefb8 100%); /*#faf9ff;*/
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;

    opacity: 1;
    overflow: hidden;

    transform: translateY(0);

    transition:
        max-height .36s cubic-bezier(.22, .61, .36, 1),
        opacity .22s ease,
        transform .30s ease,
        padding .30s ease,
        margin-top .30s ease,
        border-color .20s ease;
}

.multi-popover.hidden {
    max-height: 0;

    opacity: 0;

    padding-top: 0;
    padding-bottom: 0;

    margin-top: 0;

    border-color: transparent;

    transform: translateY(-6px);

    pointer-events: none;
}

.multi-cdu-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jump-cdu {
    border: 0;
    background: transparent;
    color: var(--arrangor-blue-dark); /* #6b57b8;*/
    font-weight: 730;
    cursor: pointer;
    padding: 0;
}

/* Liens Code ID préparés comme en V5 */ 

.link-cell {
    width: 70px;
    text-align: right;
}

.external-link.disabled {
    color: #a9b0b6;
    pointer-events: none;
}

/* Bouton de vérification CDU reste visuellement identique au lien actuel */ 

.link-button {
    border: 0;
    background: transparent;
    padding: 0;
}

/* Feedback copie */ 

.copy-btn.copied {
    border-color: var(--accent);
    color: var(--accent);
    background: #e5f5f8;
}

/* ===== Aperçu produit IKEA ===== */

.product-panel {
    margin-top: 28px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fbfcfd;
    overflow: hidden;
}

.product-panel.hidden {
    display: none;
}

.product-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    padding: 18px 20px;

    border-bottom: 1px solid var(--border);
}

.product-head h4 {
    margin: 4px 0 0;
}

.product-result {
    padding: 20px;
}

.product-loading,
.product-error,
.product-empty {
    padding: 14px;
    border-radius: 12px;
}

.product-loading {
    background: #f7fafc;
}

.product-error {
    background: #fff0f0;
    color: #8a2f2f;
}


/* Carte */

.product-card {
    display: grid;

    grid-template-columns:
        minmax(150px, 190px)
        minmax(0, 1fr);

    gap: 24px;

    align-items: start;
}


/* Image */

.product-image-wrap {
    display: grid;
    place-items: center;

    min-height: 180px;

    padding: 12px;

    border: 1px solid #edf0f2;
    border-radius: 14px;

    background: #fff;
}

.product-image-wrap img {
    display: block;

    width: 100%;
    max-height: 220px;

    object-fit: contain;
}

.product-image-empty {
    color: var(--muted);
    font-size: .8rem;
}


/* Informations */

.product-info h3 {
    margin: 6px 0 4px;

    font-size: 1.35rem;
}

.product-subtitle {
    color: var(--muted);

    line-height: 1.45;
}

.product-code-row {
    display: flex;
    align-items: center;

    gap: 8px;

    margin-top: 16px;

    font-size: .82rem;

    color: var(--muted);
}

.product-price {
    margin-top: 14px;

    font-size: 1.35rem;
    font-weight: 800;

    color: var(--text);
}

.product-actions {
    margin-top: 20px;
}

.product-open-link {
    display: inline-flex;
    align-items: center;

    min-height: 38px;
}

.product-link {
    white-space: nowrap;
}


/* Responsive */

@media (max-width: 720px) {

    .product-card {
        grid-template-columns: 1fr;
    }

    .product-image-wrap {
        width: min(100%, 240px);
    }

}