/* --- DESIGN SYSTEM CHANV OFFICIAL (GESTION PARC IT) --- */
:root {
    /* Palette Officielle */
    --chanv-blanc: #FFFFFF;
    --chanv-beige: #DDCBA4;
    --chanv-fibre: #F1EADA;
    --chanv-terre: #282828;

    /* Variables Fonctionnelles */
    --bg-main: var(--chanv-blanc);
    --bg-alternate: var(--chanv-fibre);
    --text-main: var(--chanv-terre);
    --accent: var(--chanv-beige);

    --glass-bg: rgba(255, 255, 255, 0.9);
    --shadow-soft: 0 4px 20px rgba(40, 40, 40, 0.05);
    --shadow-bold: 0 12px 40px rgba(40, 40, 40, 0.1);
    --radius: 12px;
    --radius-lg: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-logo-login {
    width: 180px;
    margin-bottom: 25px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.info-box {
    background: var(--chanv-fibre);
    padding: 20px;
    border-radius: var(--radius);
    text-align: left;
    margin-bottom: 25px;
    border-left: 5px solid var(--chanv-beige);
}

.info-item {
    margin-bottom: 12px;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.info-value {
    font-size: 1.1em;
    color: var(--chanv-terre);
    font-weight: 600;
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--chanv-blanc);
    background-image: radial-gradient(var(--chanv-fibre) 1px, transparent 1px);
    background-size: 40px 40px;
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

h1,
h2,
h3,
.section-num,
.dash-title {
    font-family: 'Outfit', sans-serif;
}

#app-content {
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* --- HEADER STANDARDIZÉ --- */
.main-header {
    background: var(--chanv-terre);
    color: var(--chanv-blanc);
    padding: 40px 20px 90px;
    position: relative;
    overflow: hidden;
    width: 100%;
}

.main-header::after {
    content: "";
    position: absolute;
    bottom: -50px;
    left: 0;
    width: 100%;
    height: 100px;
    background: var(--chanv-blanc);
    transform: skewY(-2deg);
}

.btn-back {
    position: relative;
    z-index: 10;
    margin-top: -20px;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 10;
    flex-wrap: wrap;
}

.logo-wrapper {
    text-decoration: none;
    display: flex;
    align-items: center;
    background: var(--chanv-fibre);
    padding: 12px 18px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    flex-shrink: 0;
}

.logo-wrapper:hover {
    filter: brightness(0.97);
    box-shadow: var(--shadow-bold);
}

.main-logo {
    height: 40px;
    display: block;
}

.header-user-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.user-details {
    text-align: right;
}

.header-user-section .user-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
}

.header-user-section .user-role {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.6);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
    object-fit: cover;
}

.header-titles h1 {
    font-size: 20px;
    font-weight: 700;
    color: white;
    margin: 0;
    line-height: 1.2;
}

.header-titles p {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 4px;
    opacity: 0.7;
}

/* --- LAYOUT & CONTENEURS --- */
.container,
.container-dashboard {
    max-width: 1200px;
    width: 95%;
    margin: 0 auto 60px auto;
    /* On retire le margin-top négatif agressif */
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.container {
    background: var(--chanv-blanc);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--chanv-fibre);
}

#view-home {
    margin-top: 20px;
}

/* --- DASHBOARD --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

.dash-card {
    background: var(--chanv-blanc);
    padding: 40px 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--chanv-fibre);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dash-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-bold);
    border-color: var(--chanv-beige);
}

.dash-icon {
    font-size: 3.5em;
    margin-bottom: 20px;
}

.dash-title {
    font-weight: 700;
    font-size: 1.3em;
    color: var(--chanv-terre);
    margin-bottom: 8px;
}

.dash-desc {
    font-size: 0.95em;
    color: #666;
}

/* --- INVENTAIRE --- */
#view-search {
    max-width: 1200px;
    width: 95%;
    margin: 0 auto;
    padding: 0 20px;
}

#listContainer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    width: 100%;
}

.card-item {
    background: var(--chanv-blanc);
    border-radius: var(--radius-lg);
    padding: 25px;
    border: 1px solid var(--chanv-fibre);
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-bold);
    border-color: var(--chanv-beige);
}

.card-title {
    font-weight: 700;
    font-family: 'Outfit';
    font-size: 1.3em;
    color: var(--chanv-terre);
}

.badge-tv {
    background: var(--chanv-fibre);
    color: var(--chanv-terre);
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.8em;
}

/* --- BOUTONS --- */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    letter-spacing: 1px;
}

.btn-primary {
    background: var(--chanv-beige);
    color: var(--chanv-terre);
}

.btn-primary:hover {
    filter: brightness(1.05);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.btn-tv,
.btn-search {
    background: var(--chanv-terre);
    color: white;
}

.btn-danger {
    background: #E53E3E;
    color: white;
}

.btn-secondary {
    background: var(--chanv-fibre);
    color: var(--chanv-terre);
    border: 1px solid var(--chanv-beige);
}

.btn-cadrer {
    background: #8B5CF6;
    color: #fff;
}

/* --- TICKETS TOOLBAR (filtre + tri + pagination) --- */
.tickets-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 20px;
    padding: 14px 16px;
    background: var(--chanv-fibre);
    border-radius: var(--radius);
}
.tickets-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tickets-filter-chips .chip {
    background: var(--chanv-blanc);
    border: 1px solid transparent;
    color: var(--chanv-terre);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: none;
    letter-spacing: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tickets-filter-chips .chip:hover {
    border-color: var(--chanv-beige);
}
.tickets-filter-chips .chip.active {
    background: var(--chanv-terre);
    color: var(--chanv-blanc);
}
.tickets-filter-chips .chip-count {
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}
.tickets-filter-chips .chip.active .chip-count {
    background: rgba(255, 255, 255, 0.18);
}
.tickets-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tickets-sort label {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--chanv-terre);
}
.tickets-sort select {
    width: auto;
    min-width: 200px;
    padding: 10px 14px;
    font-size: 13px;
    margin: 0;
}
.tickets-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.tickets-pagination .btn {
    padding: 10px 18px;
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
}
.tickets-pagination .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.tickets-page-info {
    font-size: 13px;
    color: #666;
    font-weight: 600;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(229, 62, 62, 0.25);
    color: #fff;
}

/* --- FORMULAIRES --- */
.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--chanv-terre);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

input,
select,
textarea {
    width: 100%;
    padding: 15px 18px;
    border: 1px solid var(--chanv-fibre);
    border-radius: 12px;
    background: var(--chanv-blanc);
    font-size: 15px;
    transition: var(--transition);
    color: var(--chanv-terre);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--chanv-beige);
    box-shadow: 0 0 0 3px rgba(221, 203, 164, 0.3);
}

/* --- AUTOCOMPLETE UTILISATEUR --- */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--chanv-blanc);
    border: 1px solid var(--chanv-fibre);
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: var(--shadow-bold);
    z-index: 100;
    max-height: 320px;
    overflow-y: auto;
}

.ac-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--chanv-fibre);
}

.ac-item:last-child {
    border-bottom: none;
}

.ac-item:hover {
    background: var(--chanv-fibre);
}

.ac-item.ac-empty {
    color: #999;
    font-style: italic;
    cursor: default;
    justify-content: center;
}

.ac-pic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--chanv-fibre);
    flex-shrink: 0;
}

.ac-info {
    flex: 1;
    min-width: 0;
}

.ac-name {
    font-weight: 600;
    font-size: 0.95em;
    color: var(--chanv-terre);
}

.ac-email {
    font-size: 0.8em;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge utilisateur sélectionné */
.selected-user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--chanv-fibre);
    border: 2px solid var(--chanv-beige);
    border-radius: 12px;
    margin-top: 10px;
    animation: badgeIn 0.3s ease;
}

@keyframes badgeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.badge-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--chanv-beige);
}

.selected-user-badge span {
    font-weight: 600;
    color: var(--chanv-terre);
    flex: 1;
}

.badge-clear {
    cursor: pointer;
    font-size: 1.2em;
    color: #999;
    transition: var(--transition);
    flex: 0 !important;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.badge-clear:hover {
    color: #E53E3E;
    background: rgba(229, 62, 62, 0.1);
}

/* Bouton Stock */
.btn-stock {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: transparent;
    border: 1.5px dashed #ccc;
    border-radius: 8px;
    font-size: 0.85em;
    color: #999;
    cursor: pointer;
    transition: var(--transition);
}

.btn-stock:hover {
    border-color: var(--chanv-beige);
    color: var(--chanv-terre);
    background: var(--chanv-fibre);
}

#searchInput {
    padding: 18px 30px;
    border-radius: 50px;
    border: 1px solid var(--chanv-fibre);
    font-size: 1.1em;
    margin-bottom: 40px;
}

/* --- MODALS & OVERLAYS --- */
#login-overlay,
#public-ticket-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--chanv-fibre);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.login-card {
    background: var(--chanv-blanc);
    padding: 50px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-bold);
    border: 1px solid var(--chanv-fibre);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-card h2 {
    margin-bottom: 8px;
    color: var(--chanv-terre);
    font-size: 24px;
}

.login-card p {
    color: #666;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-footer {
    margin-top: 25px;
    font-size: 13px;
    color: #999;
    cursor: pointer;
    text-decoration: underline;
    transition: var(--transition);
}

.login-footer:hover {
    color: var(--chanv-terre);
}

/* --- Public Ticket Info Box --- */
.info-box {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.info-item {
    flex: 1;
    background: var(--chanv-fibre);
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    font-weight: 600;
}

.info-value {
    font-size: 1.05em;
    color: var(--chanv-terre);
    word-break: break-word;
}

.modal-content {
    background: var(--chanv-blanc);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-bold);
    border: 1px solid var(--chanv-fibre);
    position: relative;
    max-width: 450px;
    width: 90%;
}

.ticket-card {
    background: var(--chanv-blanc);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid var(--chanv-fibre);
    border-left: 8px solid var(--chanv-beige);
}

.status-open {
    border-left-color: #E53E3E;
}

.status-done {
    border-left-color: #38A169;
}

#qrModal,
#historyModal,
#cadrageModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

/* --- Cadrage stratégique modal --- */
.cadrage-modal {
    max-width: 760px;
    width: 92%;
    max-height: 88vh;
    overflow-y: auto;
    text-align: left;
}
.cadrage-source-meta {
    font-size: 12px;
    color: #888;
    margin: -8px 0 16px;
}
.cadrage-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--chanv-fibre);
    border-radius: 12px;
    margin-bottom: 18px;
}
.cadrage-hint {
    font-size: 12px;
    color: #777;
    flex: 1;
    min-width: 180px;
}
.cadrage-owner-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.cadrage-owner-row .form-group {
    flex: 1;
    min-width: 200px;
}
#cadrageFields .form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--chanv-terre);
}
#cadrageFields textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
}
.cadrage-export-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 12px 0;
}
.cadrage-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

/* --- TOAST --- */
#toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--chanv-terre);
    color: white;
    padding: 18px 35px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: var(--shadow-bold);
    z-index: 10001;
    transition: var(--transition);
    opacity: 0;
}

#toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- HISTORIQUE --- */
.timeline-item {
    border-left: 2px solid var(--chanv-fibre);
}

.timeline-item::before {
    background: var(--chanv-beige);
}

/* --- TABLETTE --- */
@media (max-width: 1024px) {
    #listContainer {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- MOBILE --- */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .dash-card {
        padding: 18px 10px;
    }

    .dash-icon {
        font-size: 1.8em;
    }

    .dash-title {
        font-size: 0.85em;
    }

    .dash-desc {
        font-size: 0.7em;
    }

    #listContainer {
        grid-template-columns: 1fr;
    }

    /* Header — match Hub mobile layout */
    .main-header {
        padding: 20px 16px 50px;
    }
    .main-header::after {
        height: 60px;
        bottom: -30px;
    }
    .header-container {
        flex-direction: column;
        text-align: center;
        position: relative;
    }
    .header-user-section {
        position: absolute;
        top: 0;
        right: 0;
        margin: 0;
    }
    .header-titles p { font-size: 10px; }
    .user-details { display: none !important; }
    .avatar-burger-inner { padding: 3px 10px 3px 3px; }
    .avatar-burger-photo { width: 30px; height: 30px; }
    .avatar-burger-icon { width: 14px; gap: 3px; }

    /* Public ticket overlay - mobile friendly */
    .login-card {
        padding: 30px 20px;
    }

    .info-box {
        flex-direction: column;
        gap: 8px;
    }

    /* QR print section - mobile */
    #view-qr-print h2 {
        font-size: 1.2em;
    }

    #view-qr-print p {
        font-size: 0.85em;
    }

    /* Ticket cards - tighter on mobile */
    .ticket-card {
        padding: 14px;
    }

    .container {
        padding: 15px;
    }
}

/* =====================================================
   QR PRINT VIEW — TOOLBAR & COUNTER
   ===================================================== */
.qr-print-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.qr-print-toolbar input {
    flex: 1;
    min-width: 200px;
    padding: 12px 20px;
    border-radius: 50px;
    border: 2px solid var(--chanv-fibre);
    font-size: 0.95em;
}

.qr-print-toolbar .btn {
    width: auto;
    padding: 10px 18px;
    font-size: 0.85em;
}

.qr-print-counter {
    background: var(--chanv-fibre);
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.qr-counter-text {
    font-weight: 600;
    color: var(--chanv-terre);
}

.qr-counter-text #qrPrintCount {
    font-size: 1.4em;
    font-weight: 800;
}

.qr-print-counter .btn {
    width: auto;
    padding: 12px 25px;
    font-size: 0.9em;
}

.qr-print-list-container {
    max-height: 55vh;
    overflow-y: auto;
    border: 1px solid var(--chanv-fibre);
    border-radius: 12px;
    padding: 5px;
}

@media (max-width: 768px) {
    .qr-print-toolbar {
        flex-direction: column;
    }

    .qr-print-toolbar input {
        min-width: 0;
        width: 100%;
    }

    .qr-print-toolbar .btn {
        width: 100%;
    }

    .qr-print-counter {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .qr-print-counter .btn {
        width: 100%;
    }
}

/* =====================================================
   QR LABEL SELECTION UI
   ===================================================== */
.qr-select-row {
    padding: 2px 5px;
}

.qr-select-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    border: 1.5px solid transparent;
    font-size: inherit;
    text-transform: none;
    letter-spacing: normal;
    font-weight: normal;
    margin-bottom: 0;
}

.qr-select-label:hover {
    background: var(--chanv-fibre);
    border-color: var(--chanv-beige);
}

.qr-select-label.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.qr-select-label.disabled:hover {
    background: transparent;
    border-color: transparent;
}

/* Checkbox caché, apparence personnalisée */
.qr-select-cb {
    display: none;
}

.qr-select-check {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: white;
}

.qr-select-cb:checked + .qr-select-check {
    background: var(--chanv-terre);
    border-color: var(--chanv-terre);
}

.qr-select-cb:checked + .qr-select-check::after {
    content: "✓";
    color: white;
    font-size: 14px;
    font-weight: 800;
}

.qr-select-name {
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: var(--chanv-terre);
    font-size: 0.95em;
    flex: 1;
}

.qr-select-info {
    font-size: 0.8em;
    color: #999;
    white-space: nowrap;
}

/* =====================================================
   PLACEMENT MODAL — Choix d'emplacement sur AVERY
   ===================================================== */
#placementModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.placement-modal-content {
    background: var(--chanv-blanc);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-bold);
    border: 1px solid var(--chanv-fibre);
    position: relative;
    width: 95%;
    max-width: 820px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 35px 30px 25px;
    animation: placementIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes placementIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.placement-header {
    text-align: center;
    margin-bottom: 25px;
}

.placement-header h3 {
    margin: 0 0 6px;
    font-size: 1.4em;
    color: var(--chanv-terre);
}

.placement-subtitle {
    font-size: 0.88em;
    color: #888;
    margin: 0;
}

.placement-body {
    display: flex;
    gap: 25px;
    align-items: flex-start;
}

/* --- Grille visuelle AVERY --- */
.placement-sheet-wrapper {
    flex: 1;
    min-width: 0;
}

.placement-sheet-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #aaa;
    margin-bottom: 10px;
    text-align: center;
}

.placement-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    background: #f5f3ef;
    border: 2px solid var(--chanv-fibre);
    border-radius: 14px;
    padding: 12px;
    aspect-ratio: 8.5 / 11;
}

.placement-cell {
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    border: 2px dashed transparent;
    padding: 4px;
}

.placement-cell.empty {
    background: white;
    border-color: #ddd;
}

.placement-cell.empty:hover {
    border-color: var(--chanv-beige);
    background: #fdf9f3;
    transform: scale(1.04);
    box-shadow: 0 2px 12px rgba(221, 203, 164, 0.3);
}

.placement-cell.occupied {
    background: var(--chanv-terre);
    border-color: var(--chanv-terre);
    border-style: solid;
    animation: cellPlaced 0.3s ease;
}

@keyframes cellPlaced {
    from { transform: scale(0.85); opacity: 0.5; }
    to   { transform: scale(1); opacity: 1; }
}

.placement-cell.occupied:hover {
    background: #3a3a3a;
    transform: scale(1.04);
}

.placement-cell.drag-over {
    border-color: var(--chanv-beige) !important;
    background: rgba(221, 203, 164, 0.2) !important;
    transform: scale(1.06);
    box-shadow: 0 0 0 3px rgba(221, 203, 164, 0.4);
}

.placement-cell-num {
    font-size: 0.75em;
    font-weight: 700;
    color: #ccc;
    font-family: 'Outfit', sans-serif;
}

.placement-cell-name {
    font-size: 0.6em;
    font-weight: 700;
    color: white;
    line-height: 1.15;
    word-break: break-word;
    max-width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.placement-cell-hint {
    font-size: 0.55em;
    color: rgba(255,255,255,0.4);
    margin-top: 1px;
    transition: all 0.2s;
}

.placement-cell.occupied:hover .placement-cell-hint {
    color: #E53E3E;
    transform: scale(1.2);
}

/* --- File d'attente --- */
.placement-queue-panel {
    width: 220px;
    flex-shrink: 0;
    background: #faf9f7;
    border: 1px solid var(--chanv-fibre);
    border-radius: 14px;
    padding: 16px;
    max-height: 460px;
    display: flex;
    flex-direction: column;
}

.placement-queue-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--chanv-fibre);
}

.placement-queue-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--chanv-terre);
    margin-bottom: 4px;
}

.placement-counter {
    font-size: 0.8em;
    color: #999;
}

.placement-counter span {
    font-weight: 800;
    color: var(--chanv-terre);
}

.machine-queue-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--chanv-fibre);
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s ease;
    font-size: 0.85em;
}

.queue-item:hover {
    border-color: var(--chanv-beige);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transform: translateX(3px);
}

.queue-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.queue-num {
    width: 20px;
    height: 20px;
    min-width: 20px;
    background: var(--chanv-fibre);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: 800;
    color: var(--chanv-terre);
}

.queue-name {
    flex: 1;
    font-weight: 600;
    color: var(--chanv-terre);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: 'Outfit', sans-serif;
}

.queue-drag-icon {
    color: #ccc;
    font-size: 1.1em;
    cursor: grab;
}

.queue-empty {
    text-align: center;
    color: #38A169;
    font-weight: 600;
    font-size: 0.85em;
    padding: 20px 0;
}

/* --- Actions --- */
.placement-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--chanv-fibre);
    flex-wrap: wrap;
}

.placement-actions .btn {
    font-size: 0.85em;
    padding: 10px 20px;
}

/* --- Mobile placement --- */
@media (max-width: 700px) {
    .placement-body {
        flex-direction: column;
    }

    .placement-queue-panel {
        width: 100%;
        max-height: 180px;
    }

    .placement-modal-content {
        padding: 20px 15px;
    }
}

/* =====================================================
   AVERY 22805 PRINT SHEET — HIDDEN ON SCREEN
   ===================================================== */
#averyPrintSheet {
    display: none;
}

/* =====================================================
   PRINT STYLES — AVERY 22805
   24 étiquettes: 4 colonnes × 6 rangées
   Label: 1.5" × 1.5" (38.1mm × 38.1mm)
   Feuille: 8.5" × 11" (US Letter)

   Approche PITCH : chaque cellule = pitch complet,
   le contenu est centré à l'intérieur.
   H-pitch: 1.8125" (1-13/16") → gap ≈ 5/16"
   V-pitch: 1.6875" (1-11/16") → gap ≈ 3/16"
   Left margin: 0.625"  |  Top margin: 0.4375"
   ===================================================== */
@media print {
    /* Cacher TOUT l'app pour ne montrer que les étiquettes */
    body * {
        visibility: hidden !important;
    }

    /* Reset body */
    body {
        background: white !important;
        background-image: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Afficher uniquement la feuille d'étiquettes */
    #averyPrintSheet,
    #averyPrintSheet * {
        visibility: visible !important;
    }

    #averyPrintSheet {
        display: grid !important;
        /* Cellules = taille du pitch (pas du label).
           Le contenu est centré dans chaque cellule via .avery-label */
        grid-template-columns: repeat(4, 1.8125in);
        grid-template-rows: repeat(6, 1.6875in);
        gap: 0;

        /* Marges calculées pour centrer la grille sur Letter
           H: (8.5 − 4×1.8125) / 2 = (8.5 − 7.25) / 2 = 0.625"
           V: (11 − 6×1.6875) / 2 = (11 − 10.125) / 2 = 0.4375" */
        padding-top: 0.4375in;
        padding-left: 0.625in;
        padding-right: 0;
        padding-bottom: 0;

        position: fixed;
        top: 0;
        left: 0;
        width: 8.5in;
        height: 11in;

        background: white;
        z-index: 99999;
    }

    .avery-label {
        /* Chaque cellule grid fait la taille du pitch.
           Le contenu visible ne dépasse pas 1.5" × 1.5" */
        width: 1.8125in;
        height: 1.6875in;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        overflow: hidden;
        box-sizing: border-box;
        page-break-inside: avoid;
    }

    .avery-qr {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .avery-qr img {
        width: 76px !important;
        height: 76px !important;
    }

    .avery-qr canvas {
        width: 76px !important;
        height: 76px !important;
    }

    .avery-name {
        margin-top: 2px;
        font-family: 'Arial', sans-serif;
        font-size: 6.5pt;
        font-weight: 700;
        color: #000;
        line-height: 1.1;
        word-break: break-all;
        max-width: 1.3in;
        overflow: hidden;
    }

    /* Paramètres de la page */
    @page {
        size: letter;
        margin: 0;
    }
}

/* --- AVATAR-BURGER BUTTON --- */
.avatar-burger-btn { position:relative; background:none; border:none; cursor:pointer; padding:0; outline:none; -webkit-tap-highlight-color:transparent; }
.avatar-burger-inner { position:relative; display:flex; align-items:center; gap:10px; padding:5px 14px 5px 5px; border-radius:50px; background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.12); transition:var(--transition); }
.avatar-burger-btn:hover .avatar-burger-inner { background:rgba(255,255,255,0.15); border-color:rgba(255,255,255,0.25); box-shadow:0 4px 20px rgba(0,0,0,0.15); }
.avatar-burger-photo { width:34px; height:34px; border-radius:50%; border:2px solid rgba(255,255,255,0.25); box-shadow:0 2px 8px rgba(0,0,0,0.15); object-fit:cover; transition:var(--transition); }
.avatar-burger-icon { display:flex; flex-direction:column; gap:4px; width:16px; }
.avatar-burger-icon span { display:block; height:2px; width:100%; background:rgba(255,255,255,0.7); border-radius:2px; transition:var(--transition); }
.avatar-burger-icon span:nth-child(2) { width:70%; }
.avatar-burger-btn:hover .avatar-burger-icon span { background:white; }
.avatar-burger-btn:hover .avatar-burger-icon span:nth-child(2) { width:100%; }

/* --- UNIVERSAL SIDEBAR --- */
.sidebar-overlay { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); backdrop-filter:blur(4px); z-index:9998; opacity:0; pointer-events:none; transition:opacity 0.3s ease; }
.sidebar-overlay.open { opacity:1; pointer-events:auto; }
.sidebar-panel { position:fixed; top:0; right:-300px; width:300px; height:100%; background:var(--chanv-terre); z-index:9999; padding:0; display:flex; flex-direction:column; transition:right 0.35s cubic-bezier(0.4,0,0.2,1); box-shadow:-8px 0 40px rgba(0,0,0,0.3); }
.sidebar-panel.open { right:0; }
.sidebar-header { flex-shrink:0; display:flex; flex-direction:column; align-items:center; gap:10px; padding:36px 24px 24px; border-bottom:1px solid rgba(255,255,255,0.1); background:linear-gradient(180deg,rgba(255,255,255,0.04) 0%,transparent 100%); }
.sidebar-avatar { width:68px; height:68px; border-radius:50%; object-fit:cover; box-shadow:0 0 0 3px rgba(221,203,164,0.3),0 4px 20px rgba(0,0,0,0.3); }
.sidebar-name { font-family:'Outfit',sans-serif; font-size:17px; font-weight:700; color:white; text-align:center; }
.sidebar-role { font-size:11px; text-transform:uppercase; letter-spacing:1.5px; color:rgba(255,255,255,0.5); }
.sidebar-body { flex:1; overflow-y:auto; padding:0 24px; }
.sidebar-favs { padding:20px 0; border-bottom:1px solid rgba(255,255,255,0.1); }
.sidebar-favs-title { font-family:'Outfit',sans-serif; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:2px; color:rgba(255,255,255,0.4); padding:0 0 12px; }
.sidebar-favs-list { display:flex; flex-direction:column; gap:2px; }
.sidebar-fav-link { display:flex; align-items:center; gap:12px; padding:10px 14px; border-radius:10px; color:rgba(255,255,255,0.85); text-decoration:none; font-size:14px; font-weight:500; transition:var(--transition); }
.sidebar-fav-link:hover { background:rgba(255,255,255,0.08); color:white; transform:translateX(4px); }
.sidebar-fav-icon { font-size:16px; width:24px; text-align:center; flex-shrink:0; }
.sidebar-fav-img { width:28px; height:28px; border-radius:6px; object-fit:contain; flex-shrink:0; background:rgba(255,255,255,0.1); padding:3px; }
.sidebar-no-favs { font-size:13px; color:rgba(255,255,255,0.35); font-style:italic; padding:8px 0; }
.sidebar-logout { flex-shrink:0; width:calc(100% - 48px); margin:0 24px 24px; justify-content:center; padding:12px; font-size:14px; }
/* =====================================================================
   MODE EMBARQUÉ GANDALF (html.gandalf-embed)
   =====================================================================
   L'app vit dans le panneau de la coquille Gandalf : le header universel
   du hub remplace le nôtre, les widgets flottants (Signaler, assistant)
   sont retirés (le rail et la palette ⌘K du hub les remplacent), et la
   typographie/l'esthétique s'alignent sur le design system Gandalf
   (tuiles compactes façon "favoris").
   ===================================================================== */

/* header local + widgets flottants : remplacés par la coquille */
html.gandalf-embed .main-header{display:none}
html.gandalf-embed #gfb-root,
html.gandalf-embed #gca-root,
html.gandalf-embed #gw-root{display:none!important}

/* typographie alignée sur Gandalf */
html.gandalf-embed body{
    font-family:'Inter',-apple-system,system-ui,sans-serif;
    background:#F4EFE3;
}
html.gandalf-embed h1,
html.gandalf-embed h2,
html.gandalf-embed h3,
html.gandalf-embed .dash-title{
    font-family:'Outfit','Inter',sans-serif;
    letter-spacing:-.02em;
}
html.gandalf-embed #view-home .container-dashboard > h1,
html.gandalf-embed .container-dashboard h1{
    font-size:22px;
    font-weight:800;
    color:#282828;
}

/* modules du tableau de bord : le look "favoris" de Gandalf */
html.gandalf-embed .dashboard-grid{
    grid-template-columns:repeat(auto-fill,minmax(132px,1fr));
    gap:10px;
    margin-top:18px;
}
html.gandalf-embed .dash-card{
    height:auto;
    padding:16px 10px 14px;
    border-radius:13px;
    border:1px solid rgba(40,34,24,.10);
    box-shadow:none;
    gap:6px;
}
html.gandalf-embed .dash-card:hover{
    transform:translateY(-2px);
    border-color:rgba(168,134,63,.32);
    box-shadow:0 8px 20px -14px rgba(40,30,10,.25);
}
html.gandalf-embed .dash-icon{font-size:26px;margin-bottom:2px;line-height:1}
html.gandalf-embed .dash-title{font-size:12.5px;font-weight:650;margin-bottom:0;line-height:1.25}
html.gandalf-embed .dash-desc{font-size:10.5px;color:rgba(40,38,34,.44);line-height:1.3}

/* le contenu respire moins haut (pas de header) */
html.gandalf-embed #app-content{padding-top:8px}

/* --- Menu top du mode embarqué (remplace le tableau de bord) --- */
html.gandalf-embed #view-home{display:none!important}
html.gandalf-embed #btnBack{display:none!important}

#gandalf-embed-nav{display:none}
html.gandalf-embed #gandalf-embed-nav{
    display:flex;
    gap:6px;
    flex-wrap:wrap;
    align-items:center;
    max-width:1200px;
    margin:0 auto;
    padding:12px 16px 4px;
    position:sticky;
    top:0;
    z-index:60;
    background:#F4EFE3;
}
html.gandalf-embed .gen-tab{
    background:#fff;
    border:1px solid rgba(40,34,24,.10);
    border-radius:999px;
    padding:8px 15px;
    font-family:'Inter',-apple-system,system-ui,sans-serif;
    font-size:12.5px;
    font-weight:600;
    color:rgba(40,38,34,.66);
    cursor:pointer;
    transition:all .15s ease;
}
html.gandalf-embed .gen-tab:hover{
    border-color:rgba(168,134,63,.32);
    color:#282828;
}
html.gandalf-embed .gen-tab.on{
    background:#A8863F;
    border-color:#A8863F;
    color:#fff;
    font-weight:700;
}
