body { background-color: #94a3b8 !important; font-family: 'Segoe UI', sans-serif; margin: 0; padding: 0; }
header { background: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
main { max-width: 900px; margin: 20px auto; padding: 0 20px; }
.bloc { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-bottom: 20px; }
.bloc-carte { background: linear-gradient(135deg, #E8EAF6 0%, #9FA8DA 100%) !important; border: 1px solid #c5cae9 !important; }
.solde { background: linear-gradient(135deg, #FF1744 0%, #7C4DFF 50%, #2979FF 100%) !important; box-shadow: 0 12px 28px rgba(0,0,0,0.25), 0 8px 10px rgba(0,0,0,0.15) !important; color: white; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.btn { padding: 8px 15px; border-radius: 5px; border: none; cursor: pointer; font-weight: bold; background: #2979FF; color: white; text-decoration: none; display: inline-block; font-size: 0.9rem; }
.btn-vert { background: #28a745; color: white; }
.btn-rouge { background: #dc3545; color: white; }
.btn-clair { background-color: #E0E0E0 !important; color: #2979FF !important; border: 1px solid #cfcfcf !important; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: bold; margin-bottom: 5px; }
.form-group input, .form-group select { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.alerte { padding: 10px; border-radius: 5px; margin-bottom: 15px; font-weight: bold; }
.alerte-erreur { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alerte-succes { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.transactions { list-style: none; padding: 0; margin: 0; }
.transactions li { padding: 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e0e0e0; flex-wrap: wrap; }
.transactions li:nth-child(even) { background-color: #e2e8f0; }
.transactions li:nth-child(odd) { background-color: #ffffff; }
.carte-bancaire { position: relative; background: linear-gradient(135deg, #FF1744 0%, #7C4DFF 50%, #2979FF 100%); border-radius: 15px; padding: 20px; color: white; box-shadow: 0 12px 28px rgba(0,0,0,0.25); width: 100%; max-width: 380px; margin: 0 auto; }
.carte-puce { width: 50px; height: 38px; background: linear-gradient(135deg, #e6c27a 0%, #d4af37 40%, #f3d472 100%); border-radius: 6px; margin-top: 10px; margin-bottom: 25px; box-shadow: inset 0 0 5px rgba(0,0,0,0.2); position: relative; }
.carte-puce::before { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: rgba(0,0,0,0.15); transform: translateX(-50%); }
.carte-puce::after { content: ''; position: absolute; top: 33%; left: 0; right: 0; height: 2px; background: rgba(0,0,0,0.15); box-shadow: 0 10px 0 rgba(0,0,0,0.15); }
.mastercard-logo { position: absolute; top: 20px; right: 20px; display: flex; }
.mastercard-logo .circle { width: 35px; height: 35px; border-radius: 50%; }
.mastercard-logo .red { background-color: #eb001b; z-index: 2; }
.mastercard-logo .orange { background-color: #f79e1b; margin-left: -15px; z-index: 1; }
.badge { padding: 3px 8px; border-radius: 12px; font-size: 0.8rem; font-weight: bold; color: white; }
.bg-vert { background-color: #28a745; }
.bg-rouge { background-color: #dc3545; }
.bg-orange { background-color: #f79e1b; }
.infos { display: grid; grid-template-columns: 200px 1fr; gap: 10px 20px; margin-top: 15px; }
.infos dt { font-weight: bold; color: #333; }
.infos dd { margin: 0; color: #555; }
.petit { font-size: 0.85rem; }
.muted { color: #888; }
.bloc h2 { border-bottom: 2px solid #cbd5e1; padding-bottom: 10px; margin-bottom: 15px; font-size: 1.2rem; }




/* --- FIX ULTIME CARTE MOBILE --- */
@media screen and (max-width: 768px) {
    /* Empêche la page de scroller sur le côté */
    body, html { overflow-x: hidden !important; }

    /* Le conteneur gris clair */
    .bloc-carte {
        padding: 15px 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* La carte elle-même */
    .carte-bancaire {
        width: 100% !important;
        max-width: 100% !important;
        padding: 15px !important;
        box-sizing: border-box !important;
        margin: 0 auto !important;
    }

    /* Le numéro de carte (cible les 16 chiffres) */
    .carte-bancaire > div[style*="font-family: monospace"] {
        font-size: 1.05rem !important; /* Réduit la police */
        letter-spacing: 1px !important; /* Réduit l'espacement */
        white-space: nowrap !important; /* Empêche de passer à la ligne */
        word-spacing: 2px !important;
        margin-bottom: 15px !important;
    }

    /* Le bas de la carte (Titulaire, Expire, CVV) */
    .carte-bancaire > div[style*="display: flex; justify-content: space-between"] {
        flex-wrap: nowrap !important; /* Force sur une ligne */
        gap: 5px !important;
    }

    .carte-bancaire strong {
        font-size: 0.8rem !important; /* Réduit la taille du nom */
        display: block !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important; /* Ajoute "..." si le nom est trop long */
    }
}

/* --- FIX POUR LE SOLDE SUR MOBILE --- */
@media screen and (max-width: 768px) {
    .solde h2 {
        font-size: 1.7rem !important; /* Réduit la taille du montant sur mobile */
        white-space: nowrap !important; /* Force à rester sur une seule ligne */
        letter-spacing: -0.5px !important; /* Rapproche légèrement les chiffres */
        margin: 5px 0 15px 0 !important;
    }
}

/* --- ALIGNEMENT PROPRE DES TRANSACTIONS SUR MOBILE --- */
@media screen and (max-width: 768px) {
    .transactions li {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important; /* Interdit de passer à la ligne */
        padding: 12px 10px !important;
    }

    /* La partie gauche (Description + Date) */
    .transactions li > div:first-child {
        flex: 1 !important; /* Prend tout l'espace disponible */
        padding-right: 15px !important; /* L'ESPACE AU MILIEU */
        min-width: 0 !important;
    }

    .transactions li > div:first-child > div:first-child {
        word-wrap: break-word !important; /* Coupe le texte s'il est trop long */
        white-space: normal !important;
    }

    /* La partie droite (Le montant) */
    .transactions li > strong {
        flex-shrink: 0 !important; /* Empêche le montant de rétrécir */
        text-align: right !important; /* Aligne les chiffres à droite */
        min-width: 110px !important; /* Force une largeur fixe pour que tous les montants soient alignés */
        display: block !important;
    }
}

/* --- REFINEMENT FINAL DES TRANSACTIONS SUR MOBILE --- */
@media screen and (max-width: 768px) {
    /* Réduire la taille générale du texte dans les transactions */
    .transactions li {
        font-size: 0.8rem !important;
    }

    /* Augmenter l'espace de séparation au milieu */
    .transactions li > div:first-child {
        padding-right: 25px !important; 
    }

    /* Ajuster la taille de la description */
    .transactions li > div:first-child > div:first-child {
        font-size: 0.85rem !important; 
    }

    /* Forcer la date et l'heure sur la même ligne et réduire la taille */
    .transactions li > div:first-child > .petit {
        font-size: 0.7rem !important;
        white-space: nowrap !important; /* Empêche de passer à la ligne */
        display: block !important;
        margin-top: 2px !important;
    }

    /* Ajuster la taille du montant */
    .transactions li > strong {
        font-size: 0.85rem !important;
        min-width: 100px !important; /* Garde l'alignement parfait */
    }
}

/* --- FORCER LE BADGE "EN COURS" SUR UNE SEULE LIGNE --- */
@media screen and (max-width: 768px) {
    .transactions .badge {
        white-space: nowrap !important; /* Force le texte à rester sur une ligne */
        display: inline-block !important;
        font-size: 0.65rem !important; /* Réduit légèrement la taille du badge */
        padding: 4px 8px !important; /* Ajuste l'espace interne */
    }
    
    /* S'assurer que le conteneur du badge ne pousse pas le reste */
    .transactions li > div:first-child > div[style*="flex-basis: 100%"] {
        margin-top: 4px !important;
    }
}

/* --- AJUSTEMENT FINAL : TAILLE ET ESPACEMENT DES TRANSACTIONS --- */
@media screen and (max-width: 768px) {
    .transactions li {
        padding: 15px 10px !important; /* Un peu plus d'espace en haut et en bas */
        align-items: flex-start !important; /* Aligne le texte et le montant en haut */
    }

    /* La partie gauche (Description + Date) */
    .transactions li > div:first-child {
        padding-right: 40px !important; /* GRAND ESPACE AU MILIEU */
        flex: 1 !important;
    }

    /* Le texte de la description */
    .transactions li > div:first-child > div:first-child {
        font-size: 0.8rem !important; /* Écriture plus petite */
        line-height: 1.2 !important;
    }

    /* La date et l'heure */
    .transactions li > div:first-child > .petit {
        font-size: 0.65rem !important; /* Date encore plus petite */
        margin-top: 5px !important;
    }

    /* Le montant à droite */
    .transactions li > strong {
        font-size: 0.8rem !important; /* Écriture du montant plus petite */
        min-width: 95px !important; /* Garde un alignement parfait */
        text-align: right !important;
        margin-top: 2px !important; /* Aligné avec la première ligne de texte */
    }

    /* Le badge "En cours" */
    .transactions .badge {
        font-size: 0.6rem !important;
        padding: 3px 7px !important;
        margin-top: 6px !important;
    }
}
