:root {
    --primary-gold: #b8860b;
    --secondary-gold: #daa520;
    --accent-blue: #4a90e2;
    --success-green: #4caf50;
    --warning-orange: #ff9800;
    --error-red: #dc3545;
    --info-blue: #5bc0de;
    --text-dark: #2E2E2E;
    --text-light: #6C757D;
    --border-light: #E9ECEF;
    --white: #FFFFFF;
    --light-gray: #F1F3F4;
    --background-light: #f9f9f9;
}

* {
    box-sizing: border-box;
    margin: 10;
    padding: 10;
}

html {
    height: 100%;
}

body {
    margin: 0;
    padding: 15px 50px;
    /* Marges latérales augmentées */
    min-height: 100%;
    font-family: 'Trebuchet MS', Arial, sans-serif;
    background-color: var(--background-light);
    line-height: 1.3;
    font-size: 14px;
}

.container {
    max-width: 1600px;
    /* Largeur maximale augmentée */
    margin: 0 auto;
    padding: 0 25px;
    /* Marges internes ajustées */
    width: 100%;
}

.header {
    background: linear-gradient(135deg, var(--primary-gold), var(--secondary-gold));
    padding: 15px 20px;
    border-radius: 25px;
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    color: white;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    position: relative;
}

.logo-circle {
    width: 50px;
    height: 50px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    overflow: hidden;
}

.logo-circle img {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

.header h1 {
    font-family: 'Trebuchet MS', Arial, sans-serif;
    color: white;
    margin: 0;
    font-size: clamp(20px, 3vw, 24px);
    font-weight: normal;
    flex: 1;
}

/* Bouton aide style */
.help-icon {
    display: inline-block;
    width: 35px;
    height: 35px;
    background-color: #cd1414;
    color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 35px;
    font-weight: bold;
    cursor: help;
    position: relative;
    font-size: 18px;
    flex-shrink: 0;
    border: none;
    transition: all 0.3s ease;
}

.help-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(205, 20, 20, 0.4);
}

.help-icon:hover .tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(5px);
}

.tooltip {
    visibility: hidden;
    opacity: 0;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    text-align: left;
    border-radius: 6px;
    padding: 15px;
    position: absolute;
    z-index: 1000;
    top: 125%;
    right: 0;
    width: 350px;
    transition: all 0.3s;
    transform: translateY(0);
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.tooltip::after {
    content: "";
    position: absolute;
    bottom: 100%;
    right: 20px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent rgba(0, 0, 0, 0.9) transparent;
}

/* Section mouvements de stock */
.mouvements-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
}

.mouvements-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-gold);
    flex-wrap: wrap;
}

.mouvements-header h2 {
    color: var(--primary-gold);
    font-size: 1.4rem;
    margin: 0;
    flex: 1;
}

.link-mouvements {
    background: linear-gradient(135deg, var(--info-blue) 0%, #31b0d5 100%);
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(91, 192, 222, 0.3);
}

.link-mouvements:hover {
    background: linear-gradient(135deg, #31b0d5 0%, var(--info-blue) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(91, 192, 222, 0.4);
    color: white;
    text-decoration: none;
}

.mouvements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.mouvement-card {
    border: 2px solid #333;
    border-radius: 4px;
    background: white;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.mouvement-card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: #f8f9fa;
    padding: 8px 10px;
    border-bottom: 1px solid #333;
}

.card-ref {
    font-weight: bold;
}

.card-designation {
    color: #0066cc;
    font-weight: bold;
    margin-top: 2px;
}

.card-body {
    padding: 8px 10px;
}

.card-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 8px;
    padding: 3px 0;
    align-items: center;
    border-bottom: 1px dotted #ccc;
}

.card-row:last-child {
    border-bottom: none;
}

.card-date {
    font-weight: bold;
    width: 60px;
}

.card-doc {
    color: #0066cc;
    font-weight: bold;
}

.card-entree {
    text-align: right;
    font-weight: bold;
    color: #28a745;
    width: 40px;
}

.card-sortie {
    text-align: right;
    font-weight: bold;
    color: #dc3545;
    width: 40px;
}

.card-pu {
    text-align: right;
    width: 50px;
    font-size: 12px;
    color: #856404;
    font-weight: bold;
}

/* Layout principal - Optimisé pour écran standard */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    /* Largeur réduite du panel droit */
    gap: 20px;
    /* Gap réduit */
    align-items: start;
}

/* Section du tableau */
.stock-table {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    margin-bottom: 20px;
    text-align: center;
    /* Ajouter cette ligne */
    width: calc(100% - 60px); /* Créer des marges */
    margin: 20px auto; /* Centrer */
}

.stock-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-gold);
    text-align: center;
    /* Ajouter si vous voulez centrer le titre aussi */
}

.stock-header h2 {
    color: var(--primary-gold);
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.stock-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 600;
    flex-wrap: wrap;
    gap: 10px;
}

/* Tableau */
.stock-table {
    width: auto;
    /* Changer de 100% à auto pour que le tableau prenne sa taille naturelle */
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0 auto;
    /* Garder cette règle pour centrer */
    background-color: white;
    display: inline-block;
    /* Ajouter cette ligne pour permettre le centrage */
    margin-bottom: 20px;
}

.stock-table thead {
    background-color: var(--accent-blue);
    color: white;
}

.stock-table th {
    padding: 10px 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
    text-align: center;
    border: 1px solid #ddd;
}

.stock-table th:nth-child(1) {
    width: 55px;
}

/* Date */
.stock-table th:nth-child(2) {
    width: 55px;
}

/* Document */
.stock-table th:nth-child(3) {
    width: 150px;
}

/* Entrées */
.stock-table th:nth-child(4) {
    width: 160px;
}

/* PU Entrée */
.stock-table th:nth-child(5) {
    width: 160px;
}

/* Sorties */
.stock-table th:nth-child(6) {
    width: 160px;
}

/* Stock Qté */
.stock-table th:nth-child(7) {
    width: 30px;
}

/* CMUP */
.stock-table th:nth-child(8) {
    width: 80px;
}

/* Valeur Stock */
.stock-table th:nth-child(9) {
    width: 90px;
}

/* Check */

.stock-table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-light);
}

.stock-table tbody tr:nth-child(even) {
    background: #fffdfd;
}

.stock-table tbody tr:hover {
    background: linear-gradient(135deg, #FFF8E1 0%, #FEF5E7 100%);
}

.stock-table td {
    padding: 3px 4px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #ddd;
}

/* Inputs */
.stock-input {
    border: 0px solid #ffffff;
    border-radius: 3px;
    padding: 5px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    background: white;
    font-family: inherit;
    width: 100%;
     box-sizing: border-box;
}

.stock-input:focus {
    outline: 2px solid var(--accent-blue);
    border-color: var(--accent-blue);
}

.date-input {
    width: 55px;
    text-align: center;
}

.doc-input {
    width: 260px;
    text-align: left;
}

.qty-input {
    width: 40px;
    text-align: center;
   font-weight: bold;
}

.qty-input-ventile-qty {
    width: 40px;
    text-align: center;
    color:  #4e9dec;
}

.price-input {
    width: 60px;
    text-align: center;
   color: #4e9dec;
}

.value-input {
    width: 100px;
    text-align: center;
}

.value-input-ventile-montant {
    width: 90px;
    text-align: center;
    color: #4e9dec;
}

/* Indicateurs de statut */
.status-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background-color: #ffffff;
    transition: all 0.3s ease;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 10px;
    color: white;
}

.status-indicator.green {
    background-color: var(--success-green);
    border-color: var(--success-green);
    color: white;
}

.status-indicator.red {
    background-color: var(--error-red);
    border-color: var(--error-red);
    color: white;
}

/* Panel droit - Largeur optimisée */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Gap réduit */
    max-width: 380px;
    /* Largeur maximale fixe */
}

/* Section stock initial - Largeur réduite */
.stock-info-section {
    background: linear-gradient(135deg, var(--light-gray) 0%, var(--white) 100%);
    border-radius: 8px;
    padding: 15px;
    /* Padding réduit */
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--primary-gold);
}

.stock-initial-title {
    font-size: 0.85rem;
    /* Taille de police réduite */
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: 6px;
}

.stock-initial-values {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stock-initial-qty {
    font-size: 1.3rem;
    /* Taille réduite */
    font-weight: bold;
    color: var(--error-red);
}

.stock-initial-price {
    font-size: 0.9rem;
    /* Taille réduite */
    font-weight: bold;
    color: var(--warning-orange);
}

/* Section calculs - Largeur optimisée */
.calculations-section {
    background: white;
    border-radius: 8px;
    padding: 15px;
    /* Padding réduit */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-left: 5px solid var(--accent-blue);
    transition: all 0.5s ease;
    max-width: 1300px;
    /* Largeur maximale fixe */
}

.calc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Gap réduit */
    margin-bottom: 15px;
    /* Marge réduite */
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-light);
}

.calc-header h3 {
    color: var(--primary-gold);
    font-size: 1rem;
    /* Taille réduite */
    margin: 0;
    font-weight: 600;
}

.calculation-row {
    margin-bottom: 15px;
    /* Marge réduite */
    padding: 12px;
    /* Padding réduit */
    background: rgba(248, 249, 250, 0.8);
    border-radius: 8px;
    border: 1px solid var(--border-light);
}

.calc-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.85rem;
    /* Taille réduite */
    margin-bottom: 10px;
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--border-light);
}

.calc-inputs-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    /* Gap réduit */
    white-space: nowrap;
    margin-bottom: 6px;
}

.calc-input {
    width: 50px;
    /* Largeur réduite */
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px 2px;
    /* Padding réduit */
    font-weight: 600;
    font-size: 0.8rem;
    /* Taille réduite */
    margin: 0 2px;
}

.calc-input:focus {
    outline: 2px solid var(--accent-blue);
    border-color: var(--accent-blue);
}

.calc-operator {
    background: var(--warning-orange);
    border: 1px solid #ccc;
    border-radius: 3px;
    width: 22px;
    /* Taille réduite */
    height: 22px;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    margin: 0 3px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.equals-sign {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-blue);
    margin: 0 5px;
}

.calc-status {
    margin-left: 8px;
    align-self: center;
}

/* Infobulles pour calculs */
.calc-tooltip {
    position: relative;
    display: inline-block;
}

.calc-tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    /* Largeur réduite */
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.9) 0%, rgba(44, 62, 80, 0.9) 100%);
    color: white;
    text-align: center;
    border-radius: 8px;
    padding: 10px;
    /* Padding réduit */
    position: absolute;
    z-index: 1000;
    bottom: 130%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 10px;
    /* Taille réduite */
    line-height: 1.4;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.calc-tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

.calc-tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
    transform: translateY(-8px);
}

/* Score de réussite */
.score-container {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    margin: 20px auto;
    max-width: 300px;
    font-weight: normal;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.score-title {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.score-display {
    font-size: 24px;
    color: #007bff;
    margin: 5px 0;
    font-weight: bold;
}

/* Système de tentatives */
.tentatives-container {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin: 15px auto;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
}

.tentatives-titre {
    font-size: 14px;
    font-weight: bold;
    color: #856404;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tentatives-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 10px 0;
}

.tentative-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ffc107;
    background: #fff;
    transition: all 0.3s ease;
}

.tentative-dot.utilisee {
    background: #dc3545;
    border-color: #dc3545;
}

.tentative-dot.actuelle {
    background: #ffc107;
    border-color: #856404;
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3);
}

.tentatives-warning {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 2px solid #dc3545;
    color: #721c24;
}

.tentatives-blocked {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border: 2px solid #17a2b8;
    color: #0c5460;
}

/* Boutons style */
.button-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.action-btn {
    position: relative;
    padding: 10px 18px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s;
    font-family: 'Trebuchet MS', Arial, sans-serif;
    min-width: 120px;
    justify-content: center;
}

.btn-verify {
    background-color: var(--success-green);
    color: white;
}

.btn-verify:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-refresh {
    background-color: var(--warning-orange);
    color: white;
}

.btn-refresh:hover {
    background-color: #f57c00;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-clear {
    background-color: var(--error-red);
    color: white;
}

.btn-clear:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-print {
    background-color: var(--info-blue);
    color: white;
}

.btn-print:hover {
    background-color: #31b0d5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Tooltips pour boutons */
.action-btn:hover .btn-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

.btn-tooltip {
    visibility: hidden;
    opacity: 0;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1000;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    transition: all 0.3s ease;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.btn-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

/* Modal d'alerte personnalisée */
.custom-alert-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    z-index: 10001;
    animation: fadeIn 0.2s ease;
}

.custom-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid #e1e5e9;
    animation: slideIn 0.3s ease-out;
}

.custom-alert-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 20px;
}

.custom-alert-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 15px;
}

.custom-alert-content {
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 25px;
    text-align: center;
}

.custom-alert-score {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    border: 1px solid #dee2e6;
}

.custom-alert-score-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-blue);
    margin-bottom: 5px;
}

.custom-alert-attempts {
    font-size: 0.95rem;
    color: var(--text-dark);
}

.custom-alert-message {
    font-size: 0.9rem;
    color: var(--text-light);
    font-style: italic;
}

.custom-alert-btn {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: block;
    margin: 0 auto;
    transition: all 0.2s ease;
}

.custom-alert-btn:hover {
    background: #357abd;
    transform: translateY(-1px);
}

.custom-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: modalSlideIn 0.3s ease-out;
    border-top: 4px solid var(--primary-gold);
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    color: var(--error-red);
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.modal-message {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 30px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
}

.modal-btn-confirm {
    background-color: var(--error-red);
    color: white;
}

.modal-btn-confirm:hover {
    background-color: #c82333;
    transform: translateY(-2px);
}

.modal-btn-cancel {
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-light);
}

.modal-btn-cancel:hover {
    background: var(--light-gray);
    transform: translateY(-2px);
}

/* Responsive - Mise à jour des breakpoints */
@media (max-width: 1600px) {
    .main-layout {
        grid-template-columns: 1fr 360px;
        /* Réduction supplémentaire */
    }

    .right-panel {
        max-width: 360px;
    }
}

@media (max-width: 1400px) {
    .main-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .right-panel {
        flex-direction: row;
        gap: 20px;
        max-width: none;
    }

    .stock-info-section {
        flex: 0 0 220px;
    }

    .calculations-section {
        flex: 1;
        max-width: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px 15px;
        /* Marges réduites sur mobile */
    }

    .container {
        padding: 0 10px;
    }

    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .stock-info {
        flex-direction: column;
        gap: 5px;
    }

    .right-panel {
        flex-direction: column;
    }

    .button-container {
        flex-direction: column;
        align-items: center;
    }

    .action-btn {
        width: 200px;
    }

    .modal-content {
        margin: 20% auto;
        width: 350px;
        padding: 25px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-btn {
        width: 100%;
    }

    .btn-tooltip {
        display: none !important;
    }

    .mouvements-grid {
        grid-template-columns: 1fr;
        max-height: 300px;
    }

    .stock-table {
        font-size: 0.7rem;
    }

    .stock-input {
        font-size: 0.7rem;
        padding: 3px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translate(-50%, -60%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}


.calc-formula-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    font-size: 1.1rem;
    font-weight: bold;
}

.calc-input-yellow {
    background-color: #F5D061;
    border: 2px solid #D4A724;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    min-width: 80px;
}

.calc-result {
    min-width: 100px;
    background-color: #F5D061;
}

.calc-formula-selection {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
    font-size: 1.1rem;
    font-weight: bold;
    justify-content: center;
    flex-wrap: wrap;
}

.calc-select {
    background-color: #E5E5E5;
    border: 2px solid #999;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    min-width: 150px;
    cursor: pointer;
}

.verification-btn {
    background-color: #B91C1C;
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.verification-btn:hover {
    background-color: #DC2626;
}

.calc-title {
    font-weight: bold;
    color: #8B5CF6;
    margin-bottom: 5px;
}

.calculation-row {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #F9FAFB;
    border-radius: 8px;
    border-left: 4px solid #8B5CF6;
}


/* Section justification des calculs - Version modernisée et détaillée */

.calculations-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary-gold);
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.calculations-section:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.calc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-light);
}

.calc-header h3 {
    color: var(--primary-gold);
    font-size: 1.15rem;
    margin: 0;
    font-weight: 600;
    flex: 1;
}

.calculations-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

/* Rangées de calculs détaillées */
.calculation-row-detailed {
    background: linear-gradient(135deg, #fafbfc 0%, #f8f9fa 100%);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.calculation-row-detailed::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(135deg, var(--accent-blue), #357abd);
    border-radius: 0 2px 2px 0;
}

.calculation-row-detailed:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
}

.calc-title-detailed {
    font-weight: 600;
    color: var(--accent-blue);
    font-size: 1rem;
    margin-bottom: 15px;
    text-align: center;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.1) 0%, rgba(53, 122, 189, 0.1) 100%);
    border-radius: 25px;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;
}

.calc-formula-detailed {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: nowrap;
    margin: 0;
    font-size: 1rem;
    min-height: 45px;
    overflow-x: auto;
    padding: 5px 0;
}

/* Types d'inputs différenciés */
.calc-input-value {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid var(--accent-blue);
    border-radius: 6px;
    padding: 8px 6px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    width: 190px;
    max-width: 150px;
    transition: all 0.3s ease;
    color: var(--text-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.calc-input-value:focus {
    outline: none;
    border-color: var(--primary-gold);
    box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.2);
    background: white;
    transform: scale(1.02);
}

/* Assurer qu'aucun élément ne se compresse */
.calc-input-value,
.calc-input-result,
.calc-input-rounded,
.calc-input-operator,
.parenthesis,
.equals,
.arrow {
    flex-shrink: 0;
}

.calc-input-operator {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    border: 2px solid #d4a724;
    border-radius: 50%;
    padding: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
    width: 30px;
    height: 30px;
    transition: all 0.3s ease;
    color: #8b4513;
    box-shadow: 0 3px 6px rgba(255, 215, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.calc-input-operator:focus {
    outline: none;
    border-color: var(--warning-orange);
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
    transform: scale(1.05);
}

.calc-input-result {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0fff4 100%);
    border: 2px solid var(--success-green);
    border-radius: 6px;
    padding: 8px 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    width: 110px;
    max-width: 110px;
    transition: all 0.3s ease;
    color: var(--text-dark);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.calc-input-result:focus {
    outline: none;
    border-color: #45a049;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
    background: white;
}

.calc-input-rounded {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 2px solid var(--warning-orange);
    border-radius: 6px;
    padding: 8px 6px;
    font-size: 0.85rem;
    font-weight: bold;
    text-align: center;
    width: 90px;
    max-width: 90px;
    transition: all 0.3s ease;
    color: #8b4513;
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3);
}

.calc-input-rounded:focus {
    outline: none;
    border-color: #f57c00;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.2);
    background: #fff8dc;
}

/* Éléments de formule stylés */
.parenthesis {
    font-size: 1.4rem;
    font-weight: 300;
    color: var(--text-light);
    margin: 0 2px;
    transition: color 0.3s ease;
    flex-shrink: 0;
}

.equals {
    background: linear-gradient(135deg, var(--success-green) 0%, #45a049 100%);
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    padding: 6px 8px;
    border-radius: 6px;
    margin: 0 4px;
    box-shadow: 0 3px 6px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.equals:hover {
    transform: scale(1.05);
}

.arrow {
    font-size: 1rem;
    color: var(--warning-orange);
    font-weight: bold;
    margin: 0 4px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.arrow:hover {
    transform: scale(1.2);
    color: #f57c00;
}

/* Section sélection des éléments */
.selection-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 25px;
    margin-top: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.selection-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light);
}

.selection-header h3 {
    color: var(--primary-gold);
    font-size: 1.05rem;
    margin: 0;
    font-weight: 600;
    flex: 1;
}

.formula-selection-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.formula-selection-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    min-height: 50px;
}

.formula-result-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding-top: 15px;
    border-top: 2px dashed var(--border-light);
}

.calc-select-enhanced {
    background: white;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.85rem;
    min-width: 180px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-dark);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.calc-select-enhanced:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    transform: translateY(-1px);
}

.calc-select-enhanced:hover {
    border-color: var(--primary-gold);
    background-color: #fafbfc;
}

.calc-select-result {
    border-color: var(--success-green);
    background: linear-gradient(135deg, #f8fff9 0%, #ffffff 100%);
    font-weight: 600;
}

.calc-input-operator-small {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
    border: 2px solid #d4a724;
    border-radius: 50%;
    padding: 6px;
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
    width: 32px;
    height: 32px;
    transition: all 0.3s ease;
    color: #8b4513;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.calc-input-operator-small:focus {
    outline: none;
    border-color: var(--warning-orange);
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
    transform: scale(1.1);
}

.equals-large {
    background: linear-gradient(135deg, var(--success-green) 0%, #45a049 100%);
    color: white;
    font-weight: bold;
    font-size: 1.3rem;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
}

.equals-large:hover {
    transform: scale(1.05);
}

/* Aide contextuelle */
.selection-help {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 8px;
    border-left: 4px solid var(--info-blue);
}

.help-text {
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.5;
    margin: 0;
}

/* Indicateur de statut pour la section */
#VerifSelection {
    margin-left: auto;
    flex-shrink: 0;
}

/* Responsive design */
@media (max-width: 1024px) {

    .calc-formula-detailed,
    .formula-selection-row {
        gap: 4px;
    }

    .calc-input-value {
        width: 65px;
        max-width: 65px;
        padding: 6px 4px;
        font-size: 0.8rem;
    }

    .calc-input-result {
        width: 70px;
        max-width: 70px;
        padding: 6px 4px;
        font-size: 0.8rem;
    }

    .calc-input-rounded {
        width: 60px;
        max-width: 60px;
        padding: 6px 4px;
        font-size: 0.8rem;
    }

    .calc-select-enhanced {
        min-width: 160px;
        font-size: 0.8rem;
        padding: 10px 14px;
    }
}

@media (max-width: 768px) {
    .calculations-section {
        padding: 20px 15px;
    }

    .calc-header,
    .selection-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .calc-formula-detailed {
        justify-content: flex-start;
        gap: 3px;
        overflow-x: auto;
        min-height: 40px;
    }

    .formula-selection-row {
        justify-content: center;
        gap: 4px;
    }

    .calc-input-value {
        width: 55px;
        max-width: 55px;
        padding: 5px 3px;
        font-size: 0.75rem;
    }

    .calc-input-result {
        width: 60px;
        max-width: 60px;
        padding: 5px 3px;
        font-size: 0.75rem;
    }

    .calc-input-rounded {
        width: 50px;
        max-width: 50px;
        padding: 5px 3px;
        font-size: 0.75rem;
    }

    .calc-select-enhanced {
        min-width: 140px;
        font-size: 0.75rem;
        padding: 8px 12px;
        padding-right: 35px;
    }

    .calc-input-operator,
    .calc-input-operator-small {
        width: 25px;
        height: 25px;
        font-size: 0.75rem;
        padding: 3px;
    }

    .parenthesis {
        font-size: 1.2rem;
        margin: 0 1px;
    }

    .equals,
    .equals-large {
        font-size: 0.8rem;
        padding: 4px 6px;
        margin: 0 2px;
    }

    .arrow {
        font-size: 0.9rem;
        margin: 0 2px;
    }

    .formula-result-row {
        flex-direction: column;
        gap: 10px;
    }

    .help-text {
        font-size: 0.8rem;
    }
}

/* Animations d'entrée */
.calculation-row-detailed {
    animation: slideInUp 0.6s ease-out;
}

.calculation-row-detailed:nth-child(1) {
    animation-delay: 0.1s;
}

.calculation-row-detailed:nth-child(2) {
    animation-delay: 0.2s;
}

.calculation-row-detailed:nth-child(3) {
    animation-delay: 0.3s;
}

.calculation-row-detailed:nth-child(4) {
    animation-delay: 0.4s;
}

.selection-section {
    animation: slideInUp 0.6s ease-out 0.5s both;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* États de validation */
.calc-input-value.error,
.calc-input-operator.error,
.calc-input-result.error,
.calc-input-rounded.error {
    border-color: var(--error-red);
    background: linear-gradient(135deg, #ffebee 0%, #ffffff 100%);
    animation: shake 0.5s ease-in-out;
}

.calc-input-value.success,
.calc-input-operator.success,
.calc-input-result.success,
.calc-input-rounded.success {
    border-color: var(--success-green);
    background: linear-gradient(135deg, #e8f5e8 0%, #ffffff 100%);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}


@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}


@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}



/* Styles pour les infobulles personnalisées */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.custom-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50 !important;
    color: white !important;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: normal;
    white-space: nowrap;
    z-index: 99999;

    transition: all 0.3s ease;
    pointer-events: none;
    min-width: 140px;
    text-align: center;
    border: 2px solid #34495e;
}

.custom-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;

    border-color: #2c3e50 transparent transparent transparent;
}

.tooltip-container:hover .custom-tooltip {
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(-50%) translateY(-5px);
}

/* Style spécial pour les infobulles des opérateurs */
.custom-tooltip.operator-tooltip {
    background-color: #e74c3c !important;
    border-color: #f3b7b0 !important;
}

.custom-tooltip.operator-tooltip::after {
    border-color: #e74c3c transparent transparent transparent !important;
}

/* Style spécial pour les infobulles des résultats */
.custom-tooltip.result-tooltip {
    background-color: #27ae60 !important;
    border-color: #229954 !important;
}

.custom-tooltip.result-tooltip::after {
    border-color: #27ae60 transparent transparent transparent !important;
}

/* Ajustement pour les inputs dans les calculs */
.calc-formula-detailed .tooltip-container {
    display: inline-block;
    margin: 0 3px;
    position: relative;
    z-index: 1;
}

/* S'assurer que le conteneur parent permet les débordements */
.calc-formula-detailed {
    overflow: visible !important;
    position: relative;
}

.calculation-row-detailed {
    overflow: visible !important;
    position: relative;
}

.calculations-section {
    overflow: visible !important;
    position: relative;
}

/* Styles pour les infobulles personnalisées */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.custom-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2c3e50 !important;
    color: white !important;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: normal;
    white-space: nowrap;
    z-index: 99999;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    pointer-events: none;
    min-width: 140px;
    text-align: center;
    border: 2px solid #34495e;
}

.custom-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

.tooltip-container:hover .custom-tooltip {
    visibility: visible !important;
    opacity: 1 !important;
    transform: translateX(-50%) translateY(-5px);
}

.custom-tooltip.operator-tooltip {
    background-color: #e74c3c !important;
    border-color: #c0392b !important;
}

.custom-tooltip.operator-tooltip::after {
    border-color: #e74c3c transparent transparent transparent !important;
}

.custom-tooltip.result-tooltip {
    background-color: #27ae60 !important;
    border-color: #229954 !important;
}

.custom-tooltip.result-tooltip::after {
    border-color: #27ae60 transparent transparent transparent !important;
}

.calc-formula-detailed .tooltip-container {
    display: inline-block;
    margin: 0 3px;
    position: relative;
    z-index: 1;
}

.calc-formula-detailed {
    overflow: visible !important;
    position: relative;
}

.calculation-row-detailed {
    overflow: visible !important;
    position: relative;
}

.calculations-section {
    overflow: visible !important;
    position: relative;
}


.verification-cell {
    border: none !important;
    background: transparent !important;
}

.custom-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 10001;
    animation: fadeIn 0.3s ease;
}

.custom-alert {
    background: white;
    border: 3px solid #333;
    border-radius: 12px;
    padding: 30px;

}


  .container {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

 /* SOLUTION: Forcer les largeurs exactes dans @media print */

@media print {
    @page {
        size: A4 landscape;
        margin: 0.8cm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        font-size: 10px !important;
        line-height: 0.8 !important;
        background: white !important;
        padding: 0 !important;
        margin: 1 !important;
    }

    .container {
        max-width: none !important;
        padding: 1 !important;
        margin: 1 !important;
    }

    /* Masquer les éléments non nécessaires */
    .help-icon,
    .tooltip,
    .button-container,
    .custom-alert-overlay,
    .custom-modal,
    .btn-tooltip,
    .tentatives-container,
    .link-mouvements,
    .mouvements-section,
    .selection-section {
        display: none !important;
    }
      /* Éviter les coupures de page */
    .stock-section,
    .calculations-section,
    .score-container {
        page-break-inside: avoid;
    }

}

.footer {
    text-align: center;
    color: #666;
    font-size: 0.7rem;
    font-weight: 400;
    margin-top: 20px;
}