/* --- bloc 1 (originellement dans app.html) --- */
:root {
        --primary-color: #0A52D6;
        --sidebar-bg: #ffffff;
        --bg-body: #eef2f7; 
        --bg-card: #ffffff; 
        --text-main: #333333; 
        --text-muted: #858796; 
        --border-color: #eaecf4; 
        --input-bg: #f8f9fc; 
    }
    body.dark-mode {
        --bg-body: #121212;
        --bg-card: #1e1e1e;
        --sidebar-bg: #1a1a1a;
        --text-main: #e0e0e0;
        --text-muted: #aaaaaa;
        --border-color: #333333;
        --input-bg: #2a2a2a;
    }
    body {
        font-family: 'Inter', 'Poppins', sans-serif;
        background: var(--bg-body); 
        color: var(--text-main); 
        margin: 0; 
        padding: 0; 
        display: flex; 
        width: 100vw;
        height: 100vh; 
        overflow: hidden; 
        transition: background 0.3s, color 0.3s; 
    }

   html {
        width: 100vw;
        height: 100vh;
        overscroll-behavior-y: none; /* Empêche le rebond sur mobile */
    }

    /* FIX: Doublon body supprimé — fusionné avec le premier */
    
    @media print { 
        .hide-on-print, .sidebar, .top-bar, .btn-theme-toggle, #toast-container { display: none !important; } 
        body, #app-container, .main-content { background: white !important; color: black !important; height: auto !important; overflow: visible !important; display: block !important; } 
        .card { box-shadow: none !important; border: 1px solid #ddd !important; } 
    }

    /* Toggle switch Paramètres */
    .param-toggle { position: relative; display: inline-block; width: 52px; height: 28px; flex-shrink: 0; }
    .param-toggle input { opacity: 0; width: 0; height: 0; }
    .param-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border-color); border-radius: 28px; transition: 0.3s; }
    .param-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background: white; border-radius: 50%; transition: 0.3s; }
    .param-toggle input:checked + .param-slider { background: #0A52D6; }
    .param-toggle input:checked + .param-slider:before { transform: translateX(24px); }

    /* Support RTL (Arabe) */
    [dir="rtl"] .sidebar { order: 2; margin-left: 0; margin-right: 0; }
    [dir="rtl"] .main-content { order: 1; }
    [dir="rtl"] .nav-item { flex-direction: row; }
    [dir="rtl"] .row { flex-direction: row-reverse; }
    [dir="rtl"] .vente-card { flex-direction: row-reverse; text-align: left; }
    [dir="rtl"] .looker-card { border-left: none; border-right: 5px solid; }
    [dir="rtl"] .card-blue { border-right-color: #0A52D6; } 
    [dir="rtl"] .card-green { border-right-color: #1cc88a; } 
    [dir="rtl"] .card-cyan { border-right-color: #36b9cc; } 
    [dir="rtl"] .card-yellow { border-right-color: #f6c23e; } 
    [dir="rtl"] .card-red { border-right-color: #e74a3b; }
    [dir="rtl"] .looker-card-icon { right: auto; left: 15px; }
    [dir="rtl"] .looker-card-info { padding-right: 0; padding-left: 40px; text-align: right; }
    [dir="rtl"] .alert-item { border-left: none; border-right: 4px solid #e74a3b; flex-direction: row-reverse; }
    [dir="rtl"] .alert-item.faible { border-right-color: #f6c23e; }
    [dir="rtl"] select, [dir="rtl"] input { text-align: right; }
    [dir="rtl"] .modal-content { text-align: right; }
    /* RTL : corrections générales pour une vraie transition fluide */
    [dir="rtl"] .top-bar { flex-direction: row-reverse; }
    [dir="rtl"] .nav-item:hover, [dir="rtl"] .nav-item.active { border-left: none; border-right: 5px solid var(--primary-color); }
    [dir="rtl"] .card { text-align: right; }
    [dir="rtl"] label { display: block; text-align: right; }
    [dir="rtl"] .caisse-cart-header { flex-direction: row-reverse; }
    [dir="rtl"] .caisse-summary .summary-row { flex-direction: row-reverse; }
    [dir="rtl"] .caisse-payment-row { flex-direction: row-reverse; }
    [dir="rtl"] .param-toggle { margin-left: 0; margin-right: auto; }
    [dir="rtl"] .bottom-nav { direction: rtl; }
    [dir="rtl"] #toast-container { right: auto; left: 20px; }
    [dir="rtl"] .toast::before { left: auto; right: 0; }
    [dir="rtl"] .megaphone-icon { left: auto; right: 0; box-shadow: -5px 0 10px rgba(0,0,0,0.3); }
    [dir="rtl"] .annonce-ticker { animation-direction: reverse; padding-left: 0; padding-right: 100%; }

    #splash-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-body); z-index: 9999999; display: flex; flex-direction: column; justify-content: center; align-items: center; transition: opacity 0.6s ease-out; }
    body.dark-mode #splash-screen { background: #121212; }
    .splash-loader { display: flex; gap: 8px; }
    .splash-loader span { width: 12px; height: 12px; background: var(--primary-color); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
    .splash-loader span:nth-child(1) { animation-delay: -0.32s; } .splash-loader span:nth-child(2) { animation-delay: -0.16s; }
    @keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-15px); } 100% { transform: translateY(0px); } }
    @keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
    .fade-out { opacity: 0; pointer-events: none; }

    .lang-selector { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font-family: 'Manrope', 'Poppins', sans-serif; font-weight: bold; cursor: pointer; outline: none; }

    #showcase-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #ffffff; z-index: 99998; display: none; overflow-y: auto; color: #333; font-family: 'Manrope', 'Poppins', sans-serif; scroll-behavior: smooth; overscroll-behavior: none; }
    .showcase-header { background: #fff; padding: 15px 5%; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 4px 15px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; }
    .showcase-logo { height: 85px; width: auto; margin-left: -10px; } .showcase-footer img { width: 220px; opacity: 0.9; margin-bottom: 15px;}
    
    .showcase-header-btns { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end;}
    .btn-login-showcase { background: #f8f9fc; color: #1a2639; padding: 10px 20px; border:1px solid #ddd; border-radius: 25px; font-weight: 600; cursor:pointer; transition: 0.3s; font-family: 'Manrope', 'Poppins', sans-serif; font-size:0.9rem;}
    .btn-login-showcase:hover { background: #eaecf4; }
    .btn-signup-showcase { background: #1cc88a; color: white; padding: 10px 20px; border:none; border-radius: 25px; font-weight: 600; cursor:pointer; transition: 0.3s; font-family: 'Manrope', 'Poppins', sans-serif; font-size:0.9rem;}
    .btn-signup-showcase:hover { background: #13855c; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(28, 200, 138, 0.3); }

    .showcase-hero { padding: 80px 5% 60px; text-align: center; background: linear-gradient(135deg, #f8f9fc 0%, #eef2f7 100%); }
    .showcase-hero h1 { font-size: 2.2rem; font-weight: 800; color: #1a2639; margin-bottom: 20px; line-height: 1.3; }
    .showcase-hero h1 span { color: var(--primary-color); }
    .showcase-hero p { font-size: 1rem; color: #666; max-width: 600px; margin: 0 auto 30px; line-height:1.6;}
    .showcase-cta { display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
    
    .btn-main-showcase { background: #1cc88a; color: white; padding: 15px 30px; border:none; border-radius: 30px; font-size: 1rem; font-weight: 700; cursor:pointer; transition: 0.3s; display: inline-flex; align-items: center; gap: 10px; font-family: 'Manrope', 'Poppins', sans-serif;}
    .btn-main-showcase:hover { background: #13855c; transform: translateY(-3px); box-shadow: 0 8px 20px rgba(28, 200, 138, 0.3); }
    .btn-secondary-showcase { background: var(--primary-color); color: white; padding: 15px 30px; border:none; border-radius: 30px; font-size: 1rem; font-weight: 700; cursor:pointer; transition: 0.3s; display: inline-flex; align-items: center; gap: 10px; font-family: 'Manrope', 'Poppins', sans-serif;}
    .btn-secondary-showcase:hover { background: #2e59d9; transform: translateY(-3px); box-shadow: 0 8px 20px rgba(10, 82, 214, 0.3); }
    
    .btn-contact-showcase { background: white; color: #1a2639; padding: 15px 30px; border:2px solid #ddd; border-radius: 30px; font-size: 1rem; font-weight: 600; cursor:pointer; transition: 0.3s; display: inline-flex; align-items: center; gap: 10px; font-family: 'Manrope', 'Poppins', sans-serif;}
    .btn-contact-showcase:hover { background: #f8f9fc; }

    /* Maquette PC et Carousel */
    .showcase-app-preview { margin-top: 50px; padding: 0 20px; max-width: 1000px; margin-left: auto; margin-right: auto; }
    .browser-mockup { background: #ffffff; border-radius: 12px; box-shadow: 0 25px 50px rgba(0,0,0,0.15); border: 1px solid #eaecf4; overflow: hidden; }
    .browser-header { background: #f8f9fc; padding: 12px 15px; display: flex; align-items: center; border-bottom: 1px solid #eaecf4; }
    .browser-dots { display: flex; gap: 8px; }
    .browser-dot { width: 12px; height: 12px; border-radius: 50%; }
    .dot-red { background: #ff5f56; } .dot-yellow { background: #ffbd2e; } .dot-green { background: #27c93f; }
    .browser-title { flex-grow: 1; text-align: center; font-size: 0.8rem; font-weight: 600; color: #858796; margin-right: 40px; letter-spacing: 1px; }
    
    .carousel-container { position: relative; width: 100%; padding-top: 56.25%; background: #eef2f7; overflow: hidden; }
    .carousel-slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 0.8s ease-in-out; object-fit: cover; object-position: top left; }
    .carousel-slide.active { opacity: 1; z-index: 2; }
    .carousel-indicators { display: flex; justify-content: center; gap: 10px; margin-top: 25px; }
    .dot { width: 12px; height: 12px; border-radius: 50%; background: #ddd; cursor: pointer; transition: 0.3s; }
    .dot.active { background: var(--primary-color); transform: scale(1.3); }

    .showcase-features { padding: 60px 5%; background: #fff; }
    .showcase-title { text-align: center; font-size: 1.8rem; color: #1a2639; margin-bottom: 40px; font-weight:700;}
    .showcase-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 30px; }
    .showcase-card { background: #f8f9fc; padding: 30px; border-radius: 20px; text-align: center; border: 1px solid #eaecf4; transition: 0.3s; }
    .showcase-card:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(0,0,0,0.05); }
    .showcase-card i { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 20px; }
    .showcase-card h3 { font-size: 1.1rem; margin-bottom: 15px; color: #1a2639; font-weight:700;}
    .showcase-card p { color: #666; font-size: 0.9rem; line-height:1.5;}

    .showcase-how { padding: 60px 5%; background: #1a2639; color: white; text-align: center; }
    .showcase-how .showcase-title { color: white; }
    .showcase-steps { display: flex; flex-direction: column; gap: 20px; max-width: 600px; margin: 0 auto; text-align: left;}
    .showcase-step { background: rgba(255,255,255,0.05); padding: 20px; border-radius: 15px; display: flex; align-items: center; gap: 20px; border:1px solid rgba(255,255,255,0.1);}
    .showcase-step-num { background: #1cc88a; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: 800; font-size: 1.2rem; flex-shrink: 0; color:white;}

    .showcase-pricing { padding: 60px 5%; background: #f8f9fc; text-align: center; }
    .pricing-card { background: #fff; max-width: 350px; margin: 0 auto; padding: 40px 30px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); border-top: 5px solid var(--primary-color); }
    .pricing-price { font-size: 2.5rem; font-weight: 800; color: #1a2639; margin: 20px 0; }
    .pricing-price span { font-size: 1rem; color: #666; font-weight: 500; }
    .pricing-features { list-style: none; padding: 0; margin: 0 0 30px 0; text-align: left; }
    .pricing-features li { margin-bottom: 15px; font-size: 0.95rem; color: #444; display: flex; align-items: center; gap: 10px;}
    .pricing-features li i { color: #1cc88a; font-size: 1.1rem;}

    .showcase-faq { padding: 60px 5%; background: #fff; text-align: center; }
    .faq-container { max-width: 700px; margin: 0 auto; text-align: left; }
    .faq-item { background: #f8f9fc; padding: 20px 25px; border-radius: 15px; border: 1px solid #eaecf4; margin-bottom: 15px; }
    .faq-question { font-weight: 700; color: #1a2639; margin-bottom: 10px; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
    .faq-question i { color: var(--primary-color); }
    .faq-answer { color: #666; font-size: 0.95rem; line-height: 1.6; margin: 0; padding-left: 28px;}

    .showcase-footer { background: #111; color: #aaa; padding: 40px 5%; text-align: center; }
    @media (max-width: 768px) { .showcase-hero h1 { font-size: 1.8rem; } .showcase-logo { height: 60px; } .showcase-header-btns { flex-direction: column; gap: 5px; } .btn-login-showcase, .btn-signup-showcase { padding: 5px 10px; font-size: 0.8rem;} }



    #login-screen, #signup-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-body); z-index: 99999; display: none; flex-direction: column; justify-content: center; align-items: center; overflow-y: auto; }
    .login-box { background: var(--bg-card); padding: 40px; border-radius: 20px; box-shadow: 0 15px 35px rgba(0,0,0,0.2); width: 90%; max-width: 350px; text-align: center; border: 1px solid var(--border-color); position:relative;}
    .login-box h2 { margin-top: 0; color: var(--text-main); margin-bottom: 5px; font-weight: 700;}
    .login-box input, .login-box-inner input { width: 100%; padding: 15px; margin: 10px 0 20px 0; border: 2px solid var(--border-color); border-radius: 10px; font-size: 1rem; text-align: center; box-sizing: border-box; font-family: 'Manrope', 'Poppins', sans-serif; background: var(--input-bg); color: var(--text-main); transition: 0.3s; }
    .login-box input:focus, .login-box-inner input:focus { border-color: var(--primary-color); outline: none; }
    .login-btn { width: 100%; padding: 15px; background: var(--primary-color); color: white; border: none; border-radius: 10px; font-weight: 600; font-size: 1rem; cursor: pointer; transition: 0.3s; box-shadow: 0 4px 10px rgba(10,82,214,0.2); }
    .login-btn:disabled { background: #b0c4de; cursor: not-allowed; box-shadow: none; }
    .btn-close-login { position:absolute; top:15px; right:15px; background:none; border:none; font-size:1.5rem; color:var(--text-muted); cursor:pointer; z-index:2;}

    .reset-icon-badge { width:56px; height:56px; border-radius:16px; background:rgba(10,82,214,0.12); color:#0A52D6; display:flex; align-items:center; justify-content:center; font-size:1.4rem; margin:0 auto 16px; }
    body.dark-mode .reset-icon-badge { background:rgba(10,82,214,0.22); color:#7fa8ff; }
    .reset-progress-dots { display:flex; justify-content:center; gap:6px; margin:0 0 18px; }
    .reset-progress-dots span { width:6px; height:6px; border-radius:50%; background:var(--border-color); transition:0.3s; display:block; }
    .reset-progress-dots span.active { width:18px; border-radius:3px; background:#0A52D6; }
    .reset-link-btn { width:100%; background:none; border:none; padding:12px; color:var(--text-muted); font-weight:600; font-size:0.85rem; cursor:pointer; font-family:'Manrope','Poppins',sans-serif; margin-top:6px; transition:0.2s; }
    .reset-link-btn:hover { color:var(--text-main); }

    .auth-modal { display:flex; width:100%; min-height:100%; max-width:none; max-height:none; border-radius:0; overflow:hidden; box-shadow:none; background:var(--bg-card); text-align:left; }
    .auth-visual { order:2; flex:1; min-width:0; background:linear-gradient(160deg,#eaf1ff 0%,#d6e6ff 100%); color:#0A2E6E; padding:48px 42px; display:flex; flex-direction:column; justify-content:center; position:relative; overflow:hidden; }
    .auth-visual::after { content:''; position:absolute; bottom:-70px; left:-70px; width:220px; height:220px; border-radius:50%; background:rgba(10,82,214,0.08); }
    .auth-visual-mark { width:52px; height:52px; border-radius:14px; background:rgba(10,82,214,0.12); color:#0A52D6; display:flex; align-items:center; justify-content:center; font-size:1.4rem; margin-bottom:26px; position:relative; z-index:1; }
    .auth-visual h3 { font-family:'Manrope','Poppins',sans-serif; font-size:1.7rem; font-weight:800; margin:0 0 12px; line-height:1.28; color:#0A2E6E; position:relative; z-index:1; max-width:460px; }
    .auth-visual p.auth-sub { color:#49577a; font-size:0.95rem; margin:0 0 26px; line-height:1.5; position:relative; z-index:1; max-width:440px; }
    .auth-benefits { list-style:none; margin:0 0 28px; padding:0; display:flex; flex-direction:column; gap:16px; position:relative; z-index:1; max-width:440px; }
    .auth-benefits li { display:flex; align-items:center; gap:12px; font-size:0.86rem; color:#33415c; }
    .auth-benefits li .b-ic { width:30px; height:30px; border-radius:9px; background:rgba(10,82,214,0.12); color:#0A52D6; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:0.8rem; }
    .auth-visual-cta { position:relative; z-index:1; display:inline-flex; align-items:center; gap:8px; background:#0A52D6; color:#fff !important; font-weight:700; font-size:0.85rem; padding:12px 22px; border-radius:10px; text-decoration:none; width:fit-content; box-shadow:0 10px 22px rgba(10,82,214,0.28); }
    .auth-form-panel { order:1; flex:1; min-width:0; padding:44px; overflow-y:auto; position:relative; text-align:center; display:flex; flex-direction:column; justify-content:center; }
    .auth-form-panel .login-box-inner { width:100%; max-width:380px; margin:0 auto; }
    @media (max-width:760px){ .auth-visual{ display:none; } .auth-form-panel{ padding:40px 24px; } }
    body.dark-mode .auth-visual { background:linear-gradient(160deg,#152238 0%,#0e1726 100%); color:#e8edf7; }
    body.dark-mode .auth-visual::after { background:rgba(10,82,214,0.14); }
    body.dark-mode .auth-visual-mark { background:rgba(10,82,214,0.22); color:#7fa8ff; }
    body.dark-mode .auth-visual h3 { color:#f1f5fb; }
    body.dark-mode .auth-visual p.auth-sub { color:#a9b6cc; }
    body.dark-mode .auth-benefits li { color:#c7d1e3; }
    body.dark-mode .auth-benefits li .b-ic { background:rgba(10,82,214,0.22); color:#7fa8ff; }

  #app-container { display: none; width: 100%; height: 100%; flex: 1; flex-direction: row; }
    
    #toast-container { position: fixed; top: 20px; right: 20px; z-index: 99999999 !important; display: flex; flex-direction: column; gap: 15px; pointer-events: none; }
    .toast { min-width: 280px; padding: 16px 20px; border-radius: 12px; background: var(--bg-card); color: var(--text-main); font-weight: 600; font-size: 0.95rem; box-shadow: 0 15px 35px rgba(0,0,0,0.1); border: 1px solid var(--border-color); display: flex; align-items: center; gap: 15px; animation: slideIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards, fadeOut 0.4s ease forwards 3s; opacity: 0; transform: translateX(120%); pointer-events: auto; position: relative; overflow: hidden; }
    .toast::before { content: ''; position: absolute; left: 0; top: 0; width: 5px; height: 100%; }
    .toast.success::before { background: #1cc88a; }
    .toast.error::before { background: #e74a3b; }
    .toast.loading::before { background: #0A52D6; }
    .toast.loading { animation: slideIn 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards; opacity: 1; transform: translateX(0); }
    .toast i { font-size: 1.4rem; }
    .toast.success i { color: #1cc88a; }
    .toast.error i { color: #e74a3b; }
    .toast.loading i { color: #0A52D6; }
    @keyframes slideIn { to { transform: translateX(0); opacity: 1; } }
    @keyframes fadeOut { to { opacity: 0; transform: translateX(100%); margin-top: -60px; } }
    @keyframes spin { 100% { transform: rotate(360deg); } }
    .fa-spin-fast { animation: spin 1s linear infinite; }
    .spin-once { animation: spin 0.6s ease-out forwards; }
    /* Bouton settings : mobile uniquement */
    @media (max-width: 768px) {
        #btn-settings-mobile { display: flex !important; }
    }
    @media (min-width: 769px) {
        #btn-settings-mobile { display: none !important; }
    }
    
    #annonce-globale { display: none; background: #0A52D6; color: #ffffff; width: 100%; height: 45px; line-height: 45px; position: relative; overflow: hidden; flex-shrink: 0; border-bottom: 2px solid #f6c23e; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
    .megaphone-icon { position: absolute; left: 0; top: 0; height: 100%; background: #2e59d9; color: #ffffff; padding: 0 20px; font-weight: 800; font-size: 0.9rem; z-index: 10; display: flex; align-items: center; box-shadow: 5px 0 10px rgba(0,0,0,0.3); text-transform: uppercase; letter-spacing: 1px; }
    [dir="rtl"] .megaphone-icon { left: auto; right: 0; }
    .annonce-ticker { display: inline-block; white-space: nowrap; padding-left: 100%; font-weight: 600; font-size: 1rem; animation: defilement 50s linear infinite; }
    @keyframes defilement { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }

    .sidebar { width: 250px; background: var(--sidebar-bg); color: var(--text-main); display: flex; flex-direction: column; transition: all 0.3s; flex-shrink: 0; z-index: 100; border-right: 1px solid var(--border-color); }
    .sidebar.collapsed { margin-left: -250px; }
    [dir="rtl"] .sidebar.collapsed { margin-left: 0; margin-right: -250px; }
    /* Le bouton lui-même est stylé en inline (même look que le bouton
       "Actualiser" juste à côté, dans la top-bar) — cette classe ne gère
       plus que sa visibilité : caché sur desktop (sidebar complet déjà
       disponible), visible sur mobile (voir la media query plus bas). */
    .mobile-menu-fab { display: none; }
    .mobile-drawer-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1999;
    }
    @media (max-width: 768px) {
        /* Cacher le sidebar sur mobile */
        .sidebar { display: none !important; }
        .sidebar-overlay { display: none !important; }
        /* Ajouter padding en bas pour la bottom nav */
        .main-content { padding-bottom: 70px; }
        /* Cacher le bouton hamburger sur mobile puisqu'on a la bottom nav */
        .btn-toggle-sidebar { display: none !important; }
        /* Top bar plus compacte sur mobile */
        .top-bar { height: 55px; padding: 0 12px; }
        /* Cacher le bouton hamburger (fa-bars) dans la top-bar sur mobile —
           sauf notre propre bouton menu, qui doit au contraire s'afficher
           ici (règle ci-dessous, plus spécifique via l'ID pour l'emporter). */
        .top-bar .fa-bars { display: none !important; }
        .top-bar #mobile-menu-fab i { display: inline-block !important; }
        /* Bouton actualiser visible sur mobile */
        #btn-refresh-top { display: flex !important; }

        /* La barre du bas ne contient que 6 pages fixes (Ventes/Caisse/Stock/
           Trésorerie/Bons/Dashboard) — Dettes, Paramètres, Mode d'emploi et
           Copilote IA restent inaccessibles sans ce bouton menu, placé dans
           la top-bar (toujours visible, jamais caché par du contenu, et
           automatiquement masqué sur Caisse Scan qui passe par-dessus). */
        .mobile-menu-fab { display: flex !important; }
        .sidebar.mobile-drawer-open {
            display: flex !important;
            position: fixed;
            top: 0;
            left: 0;
            height: 100vh;
            z-index: 2000;
            box-shadow: 4px 0 24px rgba(0,0,0,0.35);
        }
        [dir="rtl"] .sidebar.mobile-drawer-open { left: auto; right: 0; }
        .mobile-drawer-backdrop.active { display: block !important; }
    }

    /* ===== BOTTOM NAVIGATION MOBILE ===== */
    .bottom-nav {
        display: none;
    }
    @media (max-width: 768px) {
        .bottom-nav {
            display: flex;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 66px;
            background: var(--input-bg, #f1f5f9);
            border-top: none;
            z-index: 1000;
            align-items: center;
            justify-content: space-around;
            padding: 6px 6px;
            gap: 4px;
            box-shadow: 0 -1px 0 var(--border-color);
        }
        /* Dark mode: fond légèrement différent */
        body.dark-mode .bottom-nav {
            background: #1a2035;
        }
        .bottom-nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            flex: 1;
            gap: 2px;
            cursor: pointer;
            padding: 6px 4px;
            border-radius: 10px;
            transition: all 0.2s ease;
            color: var(--text-muted, #94a3b8);
            font-weight: 500;
            position: relative;
            min-width: 0;
            background: transparent;
        }
        .bottom-nav-item i {
            font-size: 1.15rem;
            transition: transform 0.2s;
        }
        .bottom-nav-item span {
            font-size: 0.55rem;
            white-space: nowrap;
            letter-spacing: 0.2px;
            max-width: 54px;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: color 0.2s;
        }
        /* Actif : card blanche surélevée */
        .bottom-nav-item.active {
            color: var(--primary-color);
            background: var(--bg-card);
            box-shadow: 0 2px 8px rgba(0,0,0,0.10);
            flex: 1.35;
        }
        body.dark-mode .bottom-nav-item.active {
            background: #253055;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }
        .bottom-nav-item.active i {
            transform: scale(1.12);
        }
        /* icon-wrap : simple conteneur pour le badge */
        .bnav-icon-wrap {
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        /* Badge rouge stock */
        .bnav-badge {
            position: absolute;
            top: -5px;
            right: -7px;
            background: #e74a3b;
            color: white;
            font-size: 0.45rem;
            font-weight: 800;
            min-width: 13px;
            height: 13px;
            border-radius: 7px;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 0 2px;
            line-height: 1;
            box-shadow: 0 1px 4px rgba(231,74,59,0.5);
            border: 1.5px solid var(--input-bg, #f1f5f9);
        }
        body.dark-mode .bnav-badge {
            border-color: #1a2035;
        }
        .bnav-badge.visible { display: flex; }

    }

    /* ===== PC : mode caisse — toujours plein écran ===== */
    @media (min-width: 769px) {
        .caisse-scan-hint { font-size: 0.85rem; }
    }
    @media (max-width: 768px) {
        .caisse-scan-hint { font-size: 0.75rem; }
    }

    
    
    .sidebar-header { padding: 25px; text-align: center; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--sidebar-bg);}
    .nav-menu { padding-top: 20px; flex-grow: 1; overflow-y:auto; display: flex; flex-direction: column; }
    .nav-item { padding: 12px 25px; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 13px; transition: 0.3s; white-space: nowrap; font-weight: 500; font-size: 0.88rem; }
    .nav-item i { font-size: 0.9rem; }
    .nav-item:hover, .nav-item.active { background: rgba(10,82,214,0.08); color: var(--primary-color); border-left: 5px solid var(--primary-color); }
    .nav-group-label { padding: 18px 25px 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--text-muted); }
    .nav-menu > .nav-group-label:first-child { padding-top: 8px; }
    [dir="rtl"] .nav-item:hover, [dir="rtl"] .nav-item.active { border-left: none; border-right: 5px solid var(--primary-color); }

    .main-content { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; transition: all 0.3s; position: relative; width: 100%; min-width: 0; }
    .top-bar { background: var(--bg-card); height: 70px; display: flex; align-items: center; padding: 0 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); font-weight: 600; color: var(--text-main); justify-content: space-between; z-index: 10; flex-shrink: 0; border-bottom: 1px solid var(--border-color); }
    .container { padding: 20px; max-width: 1100px; margin: 0 auto; width: 100%; box-sizing: border-box; flex-grow: 1; min-width: 0; }
    .page { display: none; }
    .page.active { display: block; }
    .card { background: var(--bg-card); border-radius: 16px; padding: 20px; box-shadow: none; margin-bottom: 20px; border: 1px solid var(--border-color); width: 100%; box-sizing: border-box; overflow: visible; }
    /* FIX mobile: bon de commande visible et scrollable */
    @media (max-width: 768px) {
        #form-ajout-bon { overflow: visible !important; }
        #temp-list-container { overflow-x: auto !important; }
    }

    h2 { color: var(--primary-color); font-size: 1.2rem; margin-bottom: 20px; margin-top: 0; font-weight: 800; font-family: 'Manrope', 'Poppins', sans-serif; letter-spacing: -0.2px; }
    label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); display: block; margin-top: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
    select, input[type="text"], input[type="number"], input[type="date"], input[type="password"] { width: 100%; padding: 12px 15px; margin-top: 5px; border: 1.5px solid var(--border-color); border-radius: 10px; box-sizing: border-box; background: var(--input-bg); color: var(--text-main); font-family: 'Inter', 'Poppins', sans-serif; transition: 0.2s;}
    select:focus, input:focus { border-color: var(--primary-color); background: var(--bg-card); outline: none; box-shadow: 0 0 0 3px rgba(10,82,214,0.12); }

    .btn { width: 100%; padding: 15px; background: var(--primary-color); color: white; border: none; border-radius: 10px; font-weight: 700; margin-top: 25px; cursor: pointer; transition: 0.3s; box-shadow: 0 6px 16px rgba(10,82,214,0.22); font-family: 'Manrope', 'Poppins', sans-serif; letter-spacing: 0.2px; }
    .btn:hover { transform: translateY(-2px); }
    .btn-green { background: #1cc88a; box-shadow: 0 4px 10px rgba(28,200,138,0.2); }
    .btn-cancel { background: var(--bg-card); color: #c0392b; border: 1.5px solid #f3d4d0; display: none; margin-top: 10px; box-shadow: none; }
    body.dark-mode .btn-cancel { border-color: #5a3630; color: #e88a7d; }

    .vente-card { background: var(--bg-card); border-left: 5px solid var(--primary-color); padding: 15px; margin-bottom: 15px; border-radius: 14px; box-shadow: 0 1px 3px rgba(10,30,80,0.05); display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border-color); transition: 0.2s; }
    .vente-card:hover { transform: translateX(5px); box-shadow: 0 4px 14px rgba(10,30,80,0.08); }
    body.dark-mode .vente-card:hover { box-shadow: none; }
    [dir="rtl"] .vente-card:hover { transform: translateX(-5px); }
    .pay-badge { font-size: 0.65rem; font-weight: 800; padding: 5px 12px; border-radius: 20px; color: white; text-transform: uppercase; display: inline-block; margin-top: 5px; }
    .waafi { background: #1cc88a; } .dmoney { background: #f6c23e; } .sabapay { background: #0A52D6; } .cacpay { background: #36b9cc; } .cash { background: #858796; }
    .nonregle { background: #e74a3b; }

    .table-container { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 10px; }
    table { width: 100%; min-width: 600px; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; margin-top: 10px; margin-bottom: 10px; }
    th, td { padding: 12px 10px; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: middle; white-space: nowrap; }
    [dir="rtl"] th, [dir="rtl"] td { text-align: right; }
    th { background-color: var(--input-bg); color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: 0.75rem; }
    th:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
    th:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
    .badge-stock { background: rgba(10,82,214,0.1); color: var(--primary-color); padding: 5px 10px; border-radius: 8px; font-weight: 700; }
    .etat-pill { color: white; padding: 5px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; display: inline-block; text-align: center; white-space: nowrap; }
    .btn-action { cursor: pointer; border: none; background: rgba(10,82,214,0.08); font-size: 1rem; width: 32px; height: 32px; border-radius: 9px; transition: 0.2s; opacity: 0.85; display: inline-flex; align-items: center; justify-content: center;}
    .btn-action:hover { opacity: 1; transform: translateY(-1px); background: rgba(10,82,214,0.16); }
    .bon-card { border-top: 3px solid #f6c23e; }
    .bon-card .bc-title-tag { font-size: 0.95rem; letter-spacing: 0.3px; }
    .bon-card table th { font-size: 0.72rem; letter-spacing: 0.4px; }
    .row { display: flex; gap: 15px; flex-wrap: wrap;} .row > div { flex: 1; min-width: 150px;}

    .dashboard-header { margin-bottom: 30px; }
    .dashboard-title { font-size: 1.4rem; margin: 0 0 5px 0; font-weight: 700; color: var(--text-main); }
    .dashboard-subtitle { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
    .looker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 15px; margin-bottom: 30px; }
    
    .looker-card { position: relative; background: var(--bg-card); border-radius: 15px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border: 1px solid var(--border-color); border-left: 5px solid; display: flex; flex-direction: column; justify-content: center; }
    .looker-card-info { text-align: left; padding-right: 40px; }
    .looker-card-info small { display: block; color: var(--text-muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; margin-bottom: 12px; letter-spacing: 0.5px; line-height: 1.4; }
    .looker-card-info div { font-size: clamp(1.2rem, 2vw, 1.5rem); font-weight: 800; color: var(--text-main); word-wrap: break-word; }
    .looker-card-icon { position: absolute; top: 15px; right: 15px; width: 45px; height: 45px; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 1.3rem; flex-shrink: 0; }
    
   
    .card-blue .looker-card-icon { background: rgba(10,82,214,0.1); color: #0A52D6; } .card-green .looker-card-icon { background: rgba(28,200,138,0.1); color: #1cc88a; } .card-cyan .looker-card-icon { background: rgba(54,185,204,0.1); color: #36b9cc; } .card-yellow .looker-card-icon { background: rgba(246,194,62,0.1); color: #f6c23e; } .card-red .looker-card-icon { background: rgba(231,74,59,0.1); color: #e74a3b; }

    .finance-panel { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 15px; padding: 22px 24px; margin-bottom: 20px; }
    .finance-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
    .finance-panel-head h3 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
    .finance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
    .finance-item small { display: block; color: var(--text-muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
    .finance-item div { font-size: clamp(1.1rem, 2vw, 1.4rem); font-weight: 800; color: var(--text-main); }
    .finance-item.good div { color: #1cc88a; }
    .finance-item.bad div { color: #e74a3b; }
    @media (max-width: 768px) { .finance-grid { grid-template-columns: repeat(2, 1fr); } }

    .period-stat-card { margin-bottom: 20px; }
    .period-seg { display: flex; gap: 6px; }
    .period-seg-btn { border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font: 700 0.8rem/1 'Poppins', sans-serif; padding: 9px 14px; border-radius: 9px; cursor: pointer; transition: 0.2s; }
    .period-seg-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
    /* La page Dettes clients doit toujours rester visible, même sans dette
       (le code d'origine cache la carte via style="display:none" quand le
       total est à zéro, ce qui avait du sens dans l'ancien tableau de bord
       mais plus ici où c'est sa propre page). */
    #page-dettes-clients #dettes-dashboard-card { display: block !important; }
    .report-seg-btn { border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main); font: 700 0.8rem/1 'Poppins', sans-serif; padding: 9px 14px; border-radius: 9px; cursor: pointer; transition: 0.2s; }
    .report-seg-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }

    .charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; min-width: 0; width: 100%; box-sizing: border-box; overflow: hidden;}
    @media (max-width: 768px) { .charts-grid { grid-template-columns: 1fr; } }
    .chart-container { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 15px; padding: 20px; position: relative; height: 350px; overflow: hidden; width: 100%; box-sizing: border-box; min-width: 0; }
    .chart-wrapper { position: relative; height: 280px; width: 100%; padding-bottom: 15px; box-sizing: border-box; }
    .chart-title { font-size: 1rem; margin-top: 0; margin-bottom: 10px; font-weight: 700; color: var(--text-main); }

    .alert-item { background: rgba(231,74,59,0.1); border-left: 4px solid #e74a3b; padding: 10px 15px; border-radius: 8px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
    .alert-item.faible { background: rgba(246,194,62,0.1); border-left-color: #f6c23e; }

    .alert-banner-card { background: rgba(231,74,59,0.08); border-left: 4px solid #e74a3b; border-radius: 12px; padding: 14px 18px; margin-bottom: 20px; }
    .alert-banner-head { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #e74a3b; font-size: 0.9rem; margin-bottom: 8px; }
    .alert-banner-card #alertes-stock-container { display: flex; flex-wrap: wrap; gap: 8px; max-height: 130px; overflow-y: auto; }
    .alert-banner-card .alert-item { flex: 1 1 220px; margin-bottom: 0; padding: 6px 12px; font-size: 0.78rem; }
    .alert-banner-card #alertes-stock-container:empty::before { content: attr(data-empty-text); color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }

    /* backdrop-filter dropped — used by 8 modals across the app, each one
       re-blurring the ENTIRE page behind it every frame for as long as it
       stayed open. Background already opaque enough (0.6) that the blur was
       barely visible; nudged to 0.66 to keep the same darkened look. */
    .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.66); z-index: 100000; display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
    .modal-overlay.active { display: flex; opacity: 1; }
    .modal-content { background: var(--bg-card); padding: 30px; border-radius: 20px; width: 90%; max-width: 350px; text-align: center; border: 1px solid var(--border-color); transform: translateY(-20px); transition: transform 0.3s ease; color: var(--text-main); }
    .modal-overlay.active .modal-content { transform: translateY(0); }
    .modal-content i.alert-icon { font-size: 3.5rem; color: #e74a3b; margin-bottom: 20px; }
    .modal-content h3 { margin-top: 0; font-size: 1.3rem; font-weight: 700; }
    .modal-content p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 30px; line-height: 1.5; }
    .modal-actions { display: flex; gap: 15px; justify-content: center; }
    .btn-cancel-modal { padding: 12px 15px; border: none; border-radius: 10px; background: var(--border-color); color: var(--text-main); font-weight: 600; cursor: pointer; flex: 1; transition: 0.2s;}
    .btn-confirm-modal { padding: 12px 15px; border: none; border-radius: 10px; background: #e74a3b; color: white; font-weight: 600; cursor: pointer; flex: 1; transition: 0.2s;}

    .btn-theme-toggle { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); transition: 0.3s; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; padding: 0;}
    .btn-theme-toggle:hover { background: var(--input-bg); color: var(--primary-color); }

/* Bouton WhatsApp Flottant */
    .whatsapp-float {
        position: fixed;
        width: 60px;
        height: 60px;
        bottom: 30px;
        right: 30px;
        background-color: #25d366;
        color: #FFF;
        border-radius: 50px;
        text-align: center;
        font-size: 35px;
        box-shadow: 2px 2px 15px rgba(0,0,0,0.2);
        z-index: 100000;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    .whatsapp-float:hover {
        background-color: #128c7e;
        transform: scale(1.1);
    }
    @media (max-width: 768px) {
        .whatsapp-float { width: 50px; height: 50px; bottom: 20px; right: 20px; font-size: 28px; }
    }
    /* BOUTON WHATSAPP FLOTTANT */
    .whatsapp-float { 
        position: fixed; width: 60px; height: 60px; bottom: 30px; right: 30px; 
        background-color: #25d366; color: #FFF; border-radius: 50px; 
        text-align: center; font-size: 35px; box-shadow: 2px 2px 15px rgba(0,0,0,0.2); 
        z-index: 100000; display: flex; align-items: center; justify-content: center; 
        cursor: pointer; transition: all 0.3s ease; text-decoration: none;
    } 
    .whatsapp-float:hover { background-color: #128c7e; transform: scale(1.1); } 
    @media (max-width: 768px) { .whatsapp-float { width: 50px; height: 50px; bottom: 20px; right: 20px; font-size: 28px; } }

/* ========================================== */
    /* CORRECTIONS AUTOMATIQUES POUR L'ARABE (RTL)*/
    /* ========================================== */
    [dir="rtl"] #showcase-screen div, 
    [dir="rtl"] #showcase-screen p, 
    [dir="rtl"] #showcase-screen h1, 
    [dir="rtl"] #showcase-screen h2, 
    [dir="rtl"] #showcase-screen h3, 
    [dir="rtl"] #showcase-screen label {
        text-align: right !important; /* Force l'alignement à droite */
    }
    
    [dir="rtl"] .showcase-hero .word-slider {
        text-align: right !important;
        direction: rtl !important;
    }
    
    [dir="rtl"] .showcase-hero .marker-highlight::after {
        left: auto;
        right: -5%;
        transform: rotate(2deg);
    }
    
    [dir="rtl"] .faq-answer {
        padding-left: 0 !important;
        padding-right: 28px !important;
    }

    [dir="rtl"] .pricing-features li {
        flex-direction: row;
    }
    
    [dir="rtl"] .showcase-header-btns {
        flex-direction: row-reverse;
    }

.password-strength {
  height: 5px;
  border-radius: 5px;
  margin-top: 5px;
  transition: all 0.3s;
}
.strength-weak { background: #e74a3b; width: 25%; }
.strength-medium { background: #f6c23e; width: 50%; }
.strength-strong { background: #1cc88a; width: 100%; }
.strength-text {
  font-size: 0.7rem;
  margin-top: 3px;
  font-weight: 600;
}

/* --- bloc 2 (originellement dans app.html) --- */
.optima-skip-showcase #splash-screen, .optima-skip-showcase #showcase-screen { display: none !important; }

/* --- bloc 3 (originellement dans app.html) --- */
/* Fallback html5-qrcode — tuer tout l'UI parasite */
#reader-fallback > *:not(video):not(canvas) { display: none !important; }
#reader-fallback video, #reader-fallback canvas {
  width: 100% !important; height: 100% !important;
  object-fit: cover !important; display: block !important;
  position: absolute !important; top: 0 !important; left: 0 !important;
}

/* --- bloc 4 (originellement dans app.html) --- */
:root {
        --caisse-bg: #f1f5f9;
        --caisse-panel: #ffffff;
        --caisse-text: #0f172a;
        --caisse-text-light: #64748b;
        --caisse-accent: #0A52D6;
        --caisse-success: #10b981;
        --caisse-danger: #ef4444;
        --caisse-border: #e2e8f0;
        --caisse-input: #f8fafc;
    }
    body.dark-mode {
        --caisse-bg: #0f172a;
        --caisse-panel: #1e293b;
        --caisse-text: #f1f5f9;
        --caisse-text-light: #94a3b8;
        --caisse-border: #334155;
        --caisse-input: #1e293b;
    }

    /* =============================================
       LAYOUT PRINCIPAL — CAMÉRA PLEIN ÉCRAN
    ============================================= */
    /* ============================================
       CAISSE PC : 2 colonnes (scanner | panier)
    ============================================ */
    @media (min-width: 769px) {
        .caisse-pro {
            display: flex !important;
            flex-direction: row !important;
            width: 100%;
            height: 100dvh;
            background: #0f172a;
            overflow: hidden;
            position: relative;
        }

        .caisse-scanner-side {
            position: relative !important;
            inset: auto !important;
            width: 380px;
            flex-shrink: 0;
            background: #0f172a;
            border-right: 1px solid #1e293b;
            display: flex;
            flex-direction: column;
            z-index: 1;
        }

        .caisse-scanner-body {
            position: relative !important;
            inset: auto !important;
            flex: 1;
        }

        /* Cacher les éléments mobiles sur PC */
        .caisse-scan-frame,
        .caisse-scan-line,
        .caisse-scan-hint,
        .caisse-bottom-bar { display: none !important; }

        /* FIX PC: feedback barcode visible dans la colonne gauche, sous l'overlay */
        .caisse-feedback {
            position: relative !important;
            top: auto !important;
            left: auto !important;
            transform: none !important;
            width: calc(100% - 24px) !important;
            margin: 10px 12px !important;
            border-radius: 12px !important;
            padding: 12px 16px !important;
            font-size: 0.92rem !important;
            text-align: center !important;
            white-space: normal !important;
            z-index: 30 !important;
        }
        .feedback-success { display: block !important; }
        .feedback-error   { display: block !important; }

        /* PC overlay dans la colonne gauche */
        .caisse-pc-mode-overlay {
            position: absolute !important;
            top: 0 !important; left: 0 !important;
            right: 0 !important; bottom: 0 !important;
            background: #0f172a;
        }

        /* Header PC : dans le flux normal */
        .caisse-scanner-header {
            position: relative !important;
            background: #1e293b !important;
            padding: 14px 16px !important;
        }

        /* Panier PC : colonne droite scrollable */
        .caisse-cart-side {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--bg-card, #fff);
            overflow-y: auto;
            position: relative;
        }
    }

    /* ============================================
       CAISSE MOBILE : plein écran caméra
    ============================================ */
    @media (max-width: 768px) {
        .caisse-pro {
            position: relative;
            width: 100%;
            height: 100dvh;
            background: #000;
            overflow: visible;
        }

        /* === ZONE CAMÉRA : toujours plein écran === */
        .caisse-scanner-side {
            position: absolute;
            inset: 0;
            background: #000;
            z-index: 1;
        }

        .caisse-scanner-body {
            position: absolute;
            inset: 0;
            overflow: hidden;
        }

        /* Cacher le panier (remplacé par modal slide-up) */
        .caisse-cart-side { display: none !important; }
    }

    #reader-caisse {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }

    #reader-caisse video,
    #reader-caisse canvas {
        object-fit: cover !important;
        width: 100% !important;
        height: 100% !important;
        position: absolute !important;
        top: 0 !important; left: 0 !important;
    }

    #reader-caisse__scan_region {
        width: 100% !important;
        height: 100% !important;
        position: absolute !important;
        top: 0 !important; left: 0 !important;
    }

    /* Masquer tout l'UI html5-qrcode */
    #reader-caisse__dashboard,
    #reader-caisse__dashboard_section,
    #reader-caisse__dashboard_section_csr,
    #reader-caisse__dashboard_section_swaplink,
    #reader-caisse__status_span,
    #reader-caisse__header_message {
        display: none !important;
    }

    /* Mode PC douchette */
    .caisse-pc-mode-overlay {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 60px;
        background: #0f172a;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 20px;
        z-index: 2;
    }

    /* === HEADER FLOTTANT SUR LA CAMÉRA === */
    .caisse-scanner-header {
        position: absolute;
        top: 0; left: 0; right: 0;
        z-index: 20;
        padding: env(safe-area-inset-top, 10px) 14px 20px;
        padding-top: max(env(safe-area-inset-top, 0px), 10px);
        background: linear-gradient(to bottom, rgba(0,0,0,0.65) 0%, transparent 100%);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .caisse-scanner-header h2 {
        font-size: 1rem;
        font-weight: 700;
        color: white;
        margin: 0;
        text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    }

    .caisse-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .caisse-scanner-header .badge {
        /* backdrop-filter: blur was re-computed every frame over the live
           camera feed behind it — the main cause of Caisse Scan feeling
           "lourd" on phones. Already-opaque background made the blur nearly
           invisible anyway; dropped it and kept the same look without the
           per-frame GPU cost. */
        background: rgba(16,185,129,0.92);
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 0.68rem;
        font-weight: 700;
        color: white;
        animation: pulse 2s infinite;
    }

    @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }

    /* === CADRE DE SCAN CENTRÉ ET PROPORTIONNEL === */
    .caisse-scan-frame {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -58%);
        width: min(70vw, 260px);
        height: calc(min(70vw, 260px) * 0.58);
        pointer-events: none;
        z-index: 15;
    }

    .caisse-scan-frame .corner {
        position: absolute;
        width: 28px;
        height: 28px;
        border-color: #10b981;
        border-style: solid;
    }

    .corner-tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 3px 0 0 0; }
    .corner-tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 3px 0 0; }
    .corner-bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 3px; }
    .corner-br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 3px 0; }

    /* Ligne de scan DANS le cadre */
    .caisse-scan-line {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -58%);
        width: calc(min(70vw, 260px) - 14px);
        height: 2px;
        background: #10b981;
        box-shadow: 0 0 12px 3px rgba(16,185,129,0.75);
        z-index: 16;
        animation: scanInFrame 2s ease-in-out infinite;
        pointer-events: none;
    }

    @keyframes scanInFrame {
        0%   { margin-top: calc((min(70vw, 260px) * 0.58) * -0.45); }
        50%  { margin-top: calc((min(70vw, 260px) * 0.58) *  0.45); }
        100% { margin-top: calc((min(70vw, 260px) * 0.58) * -0.45); }
    }

    /* Label d'aide discret sous le cadre */
    .caisse-scan-hint {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, calc(-58% + min(70vw, 260px) * 0.58 / 2 + 14px));
        background: rgba(0,0,0,0.5);
        color: rgba(255,255,255,0.85);
        font-size: 0.72rem;
        font-weight: 500;
        padding: 4px 12px;
        border-radius: 10px;
        white-space: nowrap;
        z-index: 15;
        pointer-events: none;
    }

    /* Feedback scan (succès / erreur) */
    .caisse-feedback {
        position: absolute;
        top: 18%;
        left: 50%;
        transform: translateX(-50%);
        padding: 8px 20px;
        border-radius: 24px;
        font-weight: 700;
        font-size: 0.88rem;
        z-index: 20;
        pointer-events: none;
        transition: all 0.25s;
        white-space: nowrap;
    }

    .feedback-default { display: none; }
    .feedback-success { background: rgba(16,185,129,0.92); color: white; animation: popIn 0.3s ease; }
    .feedback-error   { background: rgba(239,68,68,0.92);  color: white; animation: shake  0.4s ease; }

    @keyframes popIn {
        0%   { transform: translateX(-50%) scale(0.8); }
        60%  { transform: translateX(-50%) scale(1.06); }
        100% { transform: translateX(-50%) scale(1); }
    }
    @keyframes shake {
        0%,100% { transform: translateX(-50%); }
        25% { transform: translateX(calc(-50% - 8px)); }
        75% { transform: translateX(calc(-50% + 8px)); }
    }

    /* === BOUTON LAMPE TORCHE === */
    #btn-torch {
        display: none;
        /* backdrop-filter dropped (see .caisse-scanner-header .badge above) —
           opacity raised to keep the icon legible over the live camera feed
           without re-blurring it every frame. */
        background: rgba(20,20,20,0.4);
        border: 1px solid rgba(255,255,255,0.3);
        color: white;
        border-radius: 8px;
        width: 36px; height: 36px;
        cursor: pointer;
        font-size: 1rem;
        align-items: center;
        justify-content: center;
        transition: 0.2s;
    }

    /* === BANDE BASSE FLOTTANTE (input + bouton panier) === */
    .caisse-bottom-bar {
        position: absolute;
        bottom: 0; left: 0; right: 0;
        z-index: 20;
        padding: 10px 12px;
        padding-bottom: max(env(safe-area-inset-bottom, 0px), 10px);
        background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    /* Champ de saisie manuel visible sur mobile aussi */
    @media (max-width: 768px) {
        #caisse-manual-input-bar { display: flex !important; }
        /* Cacher la barre de recherche PC sur mobile (doublon) */
        #caisse-pc-search-bar { display: none !important; }
    }

    /* Bouton "Voir le panier" */
    .caisse-panier-btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #10b981;
        border: none;
        border-radius: 14px;
        padding: 13px 18px;
        cursor: pointer;
        font-family: 'Manrope', 'Poppins', sans-serif;
        box-shadow: 0 4px 18px rgba(16,185,129,0.45);
        transition: 0.2s;
        width: 100%;
        box-sizing: border-box;
    }

    .caisse-panier-btn:active { transform: scale(0.98); }

    .caisse-panier-btn.empty {
        /* backdrop-filter dropped (see .caisse-scanner-header .badge above) —
           this button sits over the live camera feed for the whole scanning
           session, so re-blurring it every frame was the single biggest
           contributor to Caisse Scan feeling heavy on phones. Opacity raised
           to stay legible without it. */
        background: rgba(20,20,20,0.42);
        box-shadow: none;
        border: 1px solid rgba(255,255,255,0.25);
    }

    .panier-btn-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .panier-badge {
        background: white;
        color: #10b981;
        border-radius: 50%;
        width: 26px; height: 26px;
        display: flex; align-items: center; justify-content: center;
        font-size: 0.8rem;
        font-weight: 800;
        flex-shrink: 0;
        transition: 0.2s;
    }

    .caisse-panier-btn.empty .panier-badge {
        background: rgba(255,255,255,0.3);
        color: white;
    }

    .panier-btn-label {
        color: white;
        font-size: 0.9rem;
        font-weight: 700;
    }

    .panier-btn-total {
        color: white;
        font-size: 1rem;
        font-weight: 800;
    }

    /* Input manuel */
    .caisse-manual-input {
        display: flex;
        gap: 6px;
    }

    .caisse-manual-input input {
        flex: 1;
        padding: 9px 13px;
        border-radius: 10px;
        border: 1px solid rgba(255,255,255,0.25);
        /* backdrop-filter dropped (see .caisse-scanner-header .badge above) —
           this input also sits over the live camera feed; opacity raised to
           stay legible without re-blurring it every frame. */
        background: rgba(20,20,20,0.4);
        color: white;
        font-family: 'Manrope', 'Poppins', sans-serif;
        font-size: 0.85rem;
        outline: none;
    }

    .caisse-manual-input input::placeholder { color: rgba(255,255,255,0.55); }
    .caisse-manual-input input:focus { border-color: #0A52D6; background: rgba(255,255,255,0.18); }

    .caisse-manual-input button {
        padding: 9px 14px;
        background: #0A52D6;
        color: white;
        border: none;
        border-radius: 10px;
        font-weight: 700;
        cursor: pointer;
        font-family: 'Manrope', 'Poppins', sans-serif;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* === MODAL PANIER (SLIDE UP) — styles de base (mobile) === */
    #caisse-panier-modal {
        position: absolute;
        bottom: 0; left: 0; right: 0;
        z-index: 50;
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 22px 22px 0 0;
        background: var(--caisse-panel);
        box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
        display: flex;
        flex-direction: column;
        max-height: 90dvh;
        overflow: hidden;
    }

    /* PC : le modal panier devient une colonne droite fixe - TOUJOURS VISIBLE */
    @media (min-width: 769px) {
        #caisse-panier-modal {
            position: relative !important;
            transform: translateY(0) !important; /* FIX: toujours visible sur PC */
            height: 100dvh !important;
            border-radius: 0 !important;
            flex: 1;
            display: flex !important;
            flex-direction: column;
            box-shadow: none !important;
            overflow: hidden !important; /* FIX: pas de scroll global */
            max-height: 100dvh;
            background: var(--bg-card, #ffffff);
        }
        .modal-drag-handle { display: none; }
        #caisse-modal-overlay { display: none !important; }

        /* FIX: items scrollables sur PC */
        #caisse-panier-modal .caisse-items-container {
            flex: 1;
            overflow-y: auto;
        }

        /* FIX: footer toujours en bas sur PC */
        #caisse-panier-modal .caisse-cart-footer {
            flex-shrink: 0;
            position: sticky;
            bottom: 0;
            background: var(--bg-card, #ffffff);
            border-top: 1px solid var(--caisse-border);
            box-shadow: 0 -4px 15px rgba(0,0,0,0.06);
        }
    }

    #caisse-panier-modal.open {
        transform: translateY(0);
    }

    /* Poignée drag */
    .modal-drag-handle {
        width: 40px; height: 4px;
        background: var(--caisse-border);
        border-radius: 2px;
        margin: 10px auto 0;
        flex-shrink: 0;
    }

    .caisse-cart-header {
        padding: 12px 18px 10px;
        border-bottom: 1px solid var(--caisse-border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
    }

    .caisse-cart-header h3 {
        font-size: 1.05rem;
        font-weight: 800;
        color: var(--caisse-text);
        margin: 0;
    }

    .caisse-cart-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .caisse-back-btn { display: none; }
    @media (max-width: 768px) { .caisse-back-btn { display: flex !important; } }
        width: 34px; height: 34px;
        border-radius: 8px;
        border: 1px solid var(--caisse-border);
        background: var(--caisse-panel);
        cursor: pointer;
        color: var(--caisse-text);
        font-size: 0.9rem;
        display: flex; align-items: center; justify-content: center;
        transition: 0.2s;
    }

    .caisse-items-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 10px 14px;
    }

    .caisse-empty-cart {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 140px;
        color: var(--caisse-text-light);
        gap: 4px;
    }

    .caisse-cart-item {
        display: flex;
        align-items: center;
        padding: 10px 12px;
        background: var(--caisse-input);
        border-radius: 12px;
        margin-bottom: 8px;
        border: 1px solid var(--caisse-border);
        transition: 0.15s;
        gap: 8px;
    }

    .caisse-cart-item:hover {
        border-color: var(--caisse-accent);
    }

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

    .item-info .name {
        font-weight: 700;
        font-size: 0.9rem;
        color: var(--caisse-text);
    }

    .item-info .unit-price {
        font-size: 0.75rem;
        color: var(--caisse-text-light);
        margin-top: 2px;
    }

    .item-info { flex: 1; min-width: 0; }
    .item-info .name { font-size: 0.88rem; font-weight: 600; color: var(--caisse-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .item-info .unit-price { font-size: 0.75rem; color: var(--caisse-text-light); margin-top: 2px; }

    .item-qty-controls {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    .qty-btn {
        width: 30px; height: 30px;
        border-radius: 8px;
        border: 1.5px solid var(--caisse-border);
        background: var(--caisse-panel);
        cursor: pointer;
        font-weight: 700;
        font-size: 1rem;
        color: var(--caisse-accent);
        display: flex; align-items: center; justify-content: center;
        transition: 0.15s;
    }

    .qty-btn:active { background: var(--caisse-accent); color: white; border-color: var(--caisse-accent); }

    .qty-value {
        font-weight: 700;
        min-width: 22px;
        text-align: center;
        font-size: 0.9rem;
        color: var(--caisse-text);
    }

    .item-remove {
        background: none;
        border: none;
        color: #cbd5e1;
        cursor: pointer;
        font-size: 0.95rem;
        padding: 5px;
        border-radius: 50%;
        transition: 0.2s;
        flex-shrink: 0;
    }

    .item-remove:active { color: var(--caisse-danger); background: rgba(239,68,68,0.1); }

    /* Footer du modal panier */
    .caisse-cart-footer {
        border-top: 1px solid var(--caisse-border);
        padding: 14px 16px;
        padding-bottom: max(14px, env(safe-area-inset-bottom));
        background: var(--caisse-panel);
        flex-shrink: 0;
    }

    .caisse-summary { margin-bottom: 10px; }

    .summary-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 6px;
        font-size: 0.83rem;
        color: var(--caisse-text-light);
    }

    .summary-row.total {
        font-size: 1.15rem;
        font-weight: 900;
        color: var(--caisse-text);
        border-top: 2px dashed var(--caisse-border);
        padding-top: 8px;
        margin-top: 6px;
    }

    .summary-row.total .amount { color: var(--caisse-accent); }

    .caisse-payment-row {
        display: flex;
        gap: 8px;
        margin-bottom: 10px;
    }

    .caisse-payment-select {
        flex: 1;
        padding: 10px 12px;
        border-radius: 10px;
        border: 1.5px solid var(--caisse-border);
        font-family: 'Manrope', 'Poppins', sans-serif;
        font-weight: 600;
        background: var(--caisse-input);
        color: var(--caisse-text);
        font-size: 0.85rem;
        outline: none;
        cursor: pointer;
    }

    .caisse-payment-select:focus { border-color: var(--caisse-accent); }

    .btn-vider {
        padding: 10px 14px;
        border-radius: 10px;
        border: 1.5px solid var(--caisse-border);
        background: var(--caisse-input);
        color: var(--caisse-danger);
        cursor: pointer;
        font-weight: 600;
        font-size: 0.85rem;
        transition: 0.2s;
        white-space: nowrap;
    }

    .btn-encaisser {
        width: 100%;
        padding: 15px;
        background: #10b981;
        color: white;
        border: none;
        border-radius: 14px;
        font-weight: 800;
        font-size: 1rem;
        cursor: pointer;
        font-family: 'Manrope', 'Poppins', sans-serif;
        transition: all 0.2s;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        box-shadow: 0 4px 16px rgba(16,185,129,0.35);
    }

    .btn-encaisser:active:not(:disabled) { transform: scale(0.98); }

    .btn-encaisser:disabled {
        background: #cbd5e1;
        color: #94a3b8;
        cursor: not-allowed;
        box-shadow: none;
    }

    /* Overlay sombre derrière le modal panier */
    #caisse-modal-overlay {
        position: absolute;
        inset: 0;
        /* backdrop-filter dropped — kept re-blurring the scanner behind it
           for as long as the cart stayed open; opacity raised slightly to
           keep the same darkened look. */
        background: rgba(0,0,0,0.52);
        z-index: 40;
        display: none;
    }

    #caisse-modal-overlay.open { display: block; }

    /* Mode PC : overlay dans la colonne scanner seulement */
    .caisse-pc-mode-overlay {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 60px;
        background: #0f172a;
        z-index: 5;
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 20px;
        padding: 30px 20px;
        box-sizing: border-box;
    }

    .caisse-pc-mode-overlay.visible { display: flex; }

    /* Sur mobile : jamais afficher le bloc PC douchette */
    @media (max-width: 768px) {
        .caisse-pc-mode-overlay,
        .caisse-pc-mode-overlay.visible {
            display: none !important;
        }
    }

/* --- bloc 5 (originellement dans app.html) --- */
@keyframes wifiPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
  }
  
  #network-reconnect-modal button:hover {
    background: #083f9e;
    transform: translateY(-2px);
  }
