:root {
    --linxo-green: #0a3d31;
    --linxo-light-green: #dcedc8;
    --bg-gray: #ffffff;
    --card-bg: #f1f3f5;
    --text-main: #1a1a1a;
    --text-muted: #8e8e93;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    padding-bottom: 110px;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: border-box;
}

.app-header {
    background: linear-gradient(145deg, #2a6f58, #134e3b);
    color: white;
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.avatar-settings {
    width: 35px;
    height: 35px;
    background-color: var(--linxo-light-green);
    color: var(--linxo-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.header-balance {
    text-align: center;
    margin-top: 10px;
}

.header-balance p { margin: 0; font-size: 13px; opacity: 0.9; }
.header-balance h1 { margin: 2px 0; font-size: 32px; font-weight: 600; }

.lock-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-gray); z-index: 9999;
    display: flex; justify-content: center; align-items: center;
}

.lock-content { text-align: center; padding: 20px; }
.icon-faceid { font-size: 60px; margin-bottom: 20px; }

.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-content > h1 {
    text-align: left !important;
    padding: 0 20px;
    color: var(--text-main);
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    margin: 8px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.clickable-card { cursor: pointer; transition: transform 0.1s; }
.clickable-card:active { transform: scale(0.98); }

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header-flex h2 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: -0.4px; }
.card h2 { font-size: 16px; margin: 0; font-weight: 600; }
.card-amount { font-size: 32px; margin: 10px 0 0 0; font-weight: bold; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.small-margin { margin: 0 0 20px 0; }

.linxo-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.1); /* Fin cadre gris clair en mode clair */
    border-radius: 16px;
    padding: 8px;
    box-sizing: border-box;
}

body.dark-theme .linxo-list {
    border: 1px solid rgba(255, 255, 255, 0.2); /* Fin cadre blanc en mode sombre */
}

.operation-wrapper {
    position: relative;
    overflow: hidden; 
    border-radius: 12px;
    margin-bottom: 2px;
    width: 100%;
    flex-shrink: 0; /* Empêche les cellules de se réduire en taille */
}

.op-actions {
    position: absolute;
    top: 0; right: 0; height: 100%;
    display: flex; align-items: stretch;
}

.action-btn {
    display: flex; align-items: center; justify-content: center;
    width: 70px; color: white; border: none;
    cursor: pointer; transition: filter 0.2s;
}

.action-btn:active { filter: brightness(0.8); }
.btn-edit { background-color: #ff9500; } 
.btn-delete { background-color: #ff3b30; }

/* GRILLE STRICTE POUR ÉVITER LES CHEVAUCHEMENTS ET LA RÉDUCTION */
.operation-item {
    position: relative;
    background: var(--card-bg); 
    z-index: 2;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1); 
    width: 100%;
    display: grid;
    grid-template-columns: 8px 40px minmax(0, 1fr) auto; /* Ajout d'une colonne pour l'indicateur à gauche ou à droite */
    align-items: center;
    padding: 12px 14px 12px 6px;
    border-radius: 12px;
    gap: 12px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.op-indicator {
    width: 6px;
    height: 28px;
    border-radius: 4px;
    grid-column: 1;
    justify-self: start;
}

.operation-item.swiped { transform: translateX(-140px); }

.op-left { 
    display: contents; 
}

.op-icon {
    width: 40px; 
    height: 40px;
    min-height: 40px;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 20px;
    grid-column: 2;
    flex-shrink: 0;
}

.op-details { 
    grid-column: 3;
    min-width: 0; 
}

.op-details h4 { 
    margin: 0; 
    font-size: 15px; 
    font-weight: 600; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.op-details p { 
    margin: 4px 0 0 0; 
    font-size: 12px; 
    color: var(--text-muted); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.op-right { 
    grid-column: 4;
    text-align: right; 
    white-space: nowrap;
    flex-shrink: 0;
}

.op-right h4 { 
    margin: 0; 
    font-size: 15px; 
    font-weight: 600; 
}

.op-right p { 
    margin: 4px 0 0 0; 
    font-size: 11px; 
    color: var(--text-muted); 
}

input, select {
    width: 100%; padding: 15px; margin-bottom: 15px;
    border-radius: 12px; border: 1px solid rgba(0,0,0,0.08);
    background: var(--card-bg);
    font-size: 15px; color: var(--text-main);
}

.btn-primary {
    width: 100%; padding: 15px;
    border-radius: 25px; border: none;
    background: var(--linxo-green); color: white;
    font-size: 16px; font-weight: bold; margin-top: 10px;
    cursor: pointer;
}

.segmented-control { 
    display: flex; background: rgba(0, 0, 0, 0.04); 
    border-radius: 10px; padding: 4px; margin-bottom: 20px; 
}
.segmented-control input { display: none; }
.segmented-control label {
    flex: 1; text-align: center; padding: 10px; border-radius: 8px;
    font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.segmented-control input:checked + label { 
    background: var(--card-bg); color: var(--text-main); 
    box-shadow: 0 1px 4px rgba(0,0,0,0.1); 
}

.setting-item { display: flex; justify-content: space-between; align-items: center; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { 
    position: absolute; cursor: pointer; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background-color: #e0e0e0; transition: .4s; 
}
.slider:before { 
    position: absolute; content: ""; height: 20px; width: 20px; 
    left: 4px; bottom: 4px; background-color: white; transition: .4s; 
}
input:checked + .slider { background-color: var(--linxo-green); }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

.custom-select-container { position: relative; display: inline-block; }
.form-select-container { width: 100%; margin-bottom: 15px; display: block; }

.bubble-select.dark-bubble {
    background: rgba(0, 0, 0, 0.03) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    color: var(--text-main); 
    border: 0.5px solid rgba(255, 255, 255, 0.2) !important; 
    border-radius: 14px; 
    padding: 4px 12px;
    font-size: 12px; 
    font-weight: 600;
    width: auto; 
    height: 28px;
    display: inline-flex; 
    align-items: center; 
    gap: 6px;
    cursor: pointer; 
    box-shadow: none !important;    
} 

.form-select-btn {
    width: 100%; padding: 15px; border-radius: 12px; border: 1px solid rgba(0,0,0,0.08);
    background: var(--card-bg); color: var(--text-main); font-size: 15px; text-align: left;
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%238e8e93' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat; background-position: right 15px center;
}

.dropdown-menu {
    display: none; 
    position: absolute; 
    top: 120%; 
    right: 0; 
    width: max-content; 
    min-width: 160px; 
    z-index: 1000;
    background: rgba(255, 255, 255, 0.15) !important;
    -webkit-backdrop-filter: blur(30px) saturate(200%) !important;
    backdrop-filter: blur(30px) saturate(200%) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    padding: 8px 0; 
    overflow: hidden;
}
.form-dropdown { width: 100%; max-height: 250px; overflow-y: auto; }

.dropdown-item {
    padding: 12px 20px; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background 0.2s; color: var(--text-main);
}
.dropdown-item:hover, .dropdown-item:active { background: rgba(0, 0, 0, 0.05); }
.dropdown-item.active { color: var(--linxo-green); font-weight: bold; }

/* POP-UP D'AJOUT D'OPÉRATION */
.operation-sheet-content {
    background-color: rgba(248, 249, 250, 0.85) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    color: var(--text-main) !important;
    border-radius: 28px 28px 0 0;
    padding: 20px 15px 30px 15px;
    max-height: 90vh;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
}

.sheet-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.sheet-type-switch {
    display: flex;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    padding: 3px;
}

.type-pill {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 16px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.type-pill.active {
    background: var(--card-bg);
    color: var(--text-main);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.sheet-close-btn {
    background: rgba(0, 0, 0, 0.06);
    border: none;
    color: var(--text-main);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
}

.sheet-amount-display {
    font-size: 42px;
    font-weight: bold;
    text-align: left;
    padding: 0 10px 15px 10px;
    letter-spacing: -1px;
    color: var(--text-main);
}

.currency-symbol {
    font-size: 32px;
    margin-left: 5px;
    opacity: 0.8;
}

.sheet-category-row {
    padding: 0 10px 12px 10px;
    width: 100%;
}

.sheet-category-main-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.sheet-actions-bar {
    display: flex;
    gap: 10px;
    padding: 0 10px 15px 10px;
    align-items: center;
}

.sheet-badge-btn, .sheet-icon-btn, .liquid-glass-icon {
    background: rgba(255, 255, 255, 0.6) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
}

.sheet-submit-inline-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    flex-shrink: 0;
}

.sheet-submit-inline-btn:active {
    transform: scale(0.92);
    background: rgba(0, 0, 0, 0.08) !important;
}

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 5px;
}

.numpad-grid button {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--text-main);
    font-size: 22px;
    font-weight: 500;
    height: 52px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.numpad-grid button:active { background: rgba(0, 0, 0, 0.08); }
.numpad-action-btn { font-size: 18px !important; }

/* BOTTOM BAR & MENU RAPIDE */
.bottom-bar {
    position: fixed; bottom: 25px; left: 50%; transform: translateX(-50%); 
    width: 90%; max-width: 400px; height: 70px;
    background: rgba(255, 255, 255, 0.05); 
    -webkit-backdrop-filter: blur(40px) saturate(200%); backdrop-filter: blur(30px) saturate(200%);        
    border-radius: 35px; border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05); 
    display: flex; justify-content: space-around; align-items: center;
    padding: 0 10px; z-index: 100;
}

.nav-btn {
    background: transparent; border: none; color: #8e8e93; 
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; font-size: 11px; font-weight: 600; width: 60px; height: 55px;
    border-radius: 20px; cursor: pointer; transition: all 0.2s ease;
}

.nav-btn.active { color: var(--text-main); background: rgba(0, 0, 0, 0.04); }

.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.6); z-index: 1000; align-items: flex-end; 
}

.modal-content {
    background-color: var(--card-bg); width: 100%; max-height: 80vh; overflow-y: auto;
    border-radius: 20px 20px 0 0; padding: 20px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.08); padding-bottom: 15px; margin-bottom: 15px;
}

.modal-header h2 { margin: 0; font-size: 18px; color: var(--linxo-green); }
.modal-header button { background: none; border: none; color: var(--text-muted); font-weight: bold; font-size: 14px; cursor: pointer; }

.chart-container { display: flex; align-items: center; gap: 20px; margin-top: 20px; }
.css-donut {
    width: 100px; height: 100px; border-radius: 50%;
    background: conic-gradient(#e0e0e0 0% 70%, #e58f83 70% 90%, #7b6399 90% 100%);
    position: relative;
}
.css-donut::after {
    content: ""; position: absolute; width: 84px; height: 84px;
    background: var(--card-bg); border-radius: 50%; top: 8px; left: 8px;
}
.legend-item { font-size: 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; font-weight: 500;}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ADAPTATION DU THÈME SOMBRE */
body.dark-theme {
    --bg-gray: #000000;
    --card-bg: #222225;
    --text-main: #ffffff;
    --text-muted: #8e8e93;
    background-color: var(--bg-gray);
}

body.dark-theme .card, 
body.dark-theme .modal-content, 
body.dark-theme input, 
body.dark-theme select, 
body.dark-theme .operation-item {
    background-color: var(--card-bg) !important;
    color: var(--text-main) !important;
    border-color: #262626 !important;
}

body.dark-theme .bubble-select.dark-bubble,
body.dark-theme .dropdown-menu {
    background: rgba(18, 18, 18, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: white;
}
/* body.dark-theme .dropdown-menu {
    background: rgba(20, 20, 25, 0.3) !important;
    border: 0.5px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

body.dark-theme .bubble-select.dark-bubble {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 0.5px solid rgba(255, 255, 255, 0.1) !important;
    color: white; 
}*/

body.dark-theme .bottom-bar {
    background: rgba(18, 18, 18, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.dark-theme .operation-sheet-content {
    background-color: rgba(18, 18, 18, 0.85) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .sheet-type-switch { background: rgba(255, 255, 255, 0.08); }
body.dark-theme .type-pill { color: var(--text-muted); }
body.dark-theme .type-pill.active { background: #262626; color: white; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
body.dark-theme .sheet-close-btn { background: rgba(255, 255, 255, 0.1); color: white; }

body.dark-theme .sheet-category-main-btn,
body.dark-theme .sheet-badge-btn,
body.dark-theme .sheet-icon-btn,
body.dark-theme .liquid-glass-icon {
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

body.dark-theme .numpad-grid button {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
}

.budget-item-modern {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
    cursor: pointer;
}

.budget-title { font-size: 15px; font-weight: 600; color: var(--text-main); }
.budget-gauge-box {
    position: relative;
    width: 100%;
    height: 32px;
    background-color: rgba(0,0,0,0.04);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.budget-gauge-fill {
    position: absolute; top: 0; left: 0; height: 100%;
    border-radius: 12px 0 0 12px; transition: width 0.4s ease; opacity: 0.25;
}
.budget-gauge-text {
    position: relative; width: 100%; text-align: center;
    font-size: 13px; font-weight: 600; color: var(--text-main); z-index: 2;
}

body.dark-theme .budget-gauge-box {
    background-color: rgba(255,255,255,0.05);
    border-color: #262626;
}

.liquid-glass {
    background: rgba(255, 255, 255, 0.75) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    backdrop-filter: blur(25px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body.dark-theme .liquid-glass {
    background: rgba(30, 30, 30, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* ========================================================
   VERROUILLAGE STRICT DE LA MODALE D'HISTORIQUE ET DU SCROLL
   ======================================================== */
#modal-historique {
    display: none; 
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.6); 
    z-index: 1000; 
    align-items: flex-end; 
}

#modal-historique .modal-content {
    display: flex !important;
    flex-direction: column !important;
    height: 52vh !important;
    max-height: 52vh !important;
    overflow: hidden !important;
}

#liste-depenses-complete {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    width: 100%;
    min-height: 0 !important; /* Force le défilement indépendant dans le conteneur flex */
}

#liste-depenses-complete::-webkit-scrollbar { width: 4px; }
#liste-depenses-complete::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}