:root {
    --primary: #4F46E5; --primary-dark: #4338CA; --primary-light: #EDE9FE;
    --success: #10B981; --success-light: #D1FAE5;
    --danger: #EF4444; --danger-light: #FEE2E2;
    --warning: #F59E0B; --warning-light: #FEF3C7;
    --info: #3B82F6; --bg: #F9FAFB; --card-bg: #FFFFFF;
    --border: #E5E7EB; --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 12px; --radius-sm: 8px;
    --text-primary: #1F2937; --text-secondary: #6B7280; --text-muted: #9CA3AF;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--bg) 0%, var(--primary-light) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 15px; }
.header h1 { font-size: 1.8rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 10px; }

/* ===== BALANCE & CARDS ===== */
.balance {
    font-size: 1.3rem; font-weight: 600; color: var(--primary);
    background: var(--card-bg); padding: 12px 24px; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border); transition: all 0.3s ease;
}
.balance:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.balance.negative { color: var(--danger); background: #FFF5F5; border-color: #FECACA; }

.quick-actions { display: flex; gap: 12px; margin-bottom: 25px; flex-wrap: wrap; }

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 20px; border: none; border-radius: var(--radius);
    font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
    display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow);
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border: 1px solid var(--primary); }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #3730A3); box-shadow: 0 4px 12px rgba(79,70,229,0.3); }
.btn-success { background: linear-gradient(135deg, var(--success), #059669); color: white; border: 1px solid var(--success); }
.btn-success:hover { background: linear-gradient(135deg, #059669, #047857); box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.btn-danger { background: linear-gradient(135deg, var(--danger), #DC2626); color: white; border: 1px solid var(--danger); }
.btn-danger:hover { background: linear-gradient(135deg, #DC2626, #B91C1C); box-shadow: 0 4px 12px rgba(239,68,68,0.3); }
.btn-warning { background: linear-gradient(135deg, var(--warning), #D97706); color: white; border: 1px solid var(--warning); }
.btn-warning:hover { background: linear-gradient(135deg, #D97706, #B45309); box-shadow: 0 4px 12px rgba(245,158,11,0.3); }
.btn-secondary { background: white; color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-info { background: linear-gradient(135deg, var(--info), #2563EB); color: white; border: 1px solid var(--info); }
.btn-info:hover { background: linear-gradient(135deg, #2563EB, #1D4ED8); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; }
.btn-lg { padding: 16px 28px; font-size: 1.05rem; }

/* ===== CARDS ===== */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 25px; margin-bottom: 20px; box-shadow: var(--shadow); transition: all 0.3s ease; }
.card:hover { box-shadow: var(--shadow-lg); }
.card-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

.totals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; margin-bottom: 25px; }
.total-card {
    background: var(--card-bg); color: var(--text-primary); padding: 20px; border-radius: var(--radius);
    text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border); transition: all 0.3s ease;
    position: relative; overflow: hidden;
}
.total-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); }
.total-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.total-card.warning::before { background: linear-gradient(90deg, var(--warning), #D97706); }
.total-card .label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.total-card .amount { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.total-card.warning .amount { color: var(--warning); }
.total-card.negative .amount { color: var(--danger); }

/* ===== TABLES ===== */
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; margin-top: 15px; }
.chart-container { position: relative; height: 320px; }
.breakdown-table { width: 100%; border-collapse: collapse; }
.breakdown-table th, .breakdown-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border); }
.breakdown-table th { background: var(--bg); font-weight: 600; color: var(--text-secondary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.breakdown-table tr:hover { background: var(--bg); }
.color-cell { display: flex; align-items: center; gap: 10px; }
.color-box { width: 14px; height: 14px; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.table-container { overflow-x: auto; margin-top: 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; color: var(--text-secondary); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover { background: var(--bg); }
tr:last-child td { border-bottom: none; }

/* ===== STATUS & TYPES ===== */
.status-badge { padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; cursor: pointer; user-select: none; transition: all 0.2s ease; display: inline-block; }
.status-badge:hover { opacity: 0.9; transform: scale(1.05); }
.status-paid { background: var(--success-light); color: #065F46; }
.status-unpaid { background: var(--danger-light); color: #991B1B; }
.type-expense { color: var(--danger); font-weight: 600; }
.type-income { color: var(--success); font-weight: 600; }

/* ===== MODALS ===== */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    opacity: 0; visibility: hidden; transition: all 0.3s ease; backdrop-filter: blur(4px);
}
.modal.active { opacity: 1; visibility: visible; }
.modal-content {
    background: white; border-radius: var(--radius); padding: 30px; width: 90%;
    max-width: 520px; max-height: 85vh; overflow-y: auto; transform: scale(0.9);
    transition: all 0.3s ease; box-shadow: var(--shadow-lg);
}
.modal.active .modal-content { transform: scale(1); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;
    padding-bottom: 20px; border-bottom: 2px solid var(--primary-light);
}
.modal-title { font-size: 1.4rem; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.close-modal {
    background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-secondary);
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: all 0.2s ease;
}
.close-modal:hover { background: var(--bg); color: var(--text-primary); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.form-group input, .form-group select {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius-sm);
    font-size: 1rem; background: white; transition: all 0.3s ease; font-family: inherit;
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}
.form-group input::placeholder { color: var(--text-muted); }
.modal-actions {
    display: flex; gap: 12px; justify-content: flex-end; margin-top: 25px;
    padding-top: 20px; border-top: 1px solid var(--border);
}
.modal-actions .btn { min-width: 120px; }
#importPreview {
    margin-top: 20px; max-height: 250px; overflow-y: auto; border: 1px solid var(--border);
    padding: 15px; border-radius: var(--radius-sm); display: none; background: var(--bg);
}
#previewTable { width: 100%; font-size: 0.85rem; }
#previewTable th, #previewTable td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
#previewTable th { background: white; font-weight: 600; color: var(--text-secondary); font-size: 0.8rem; }

/* ===== FOOTER & LINKS ===== */
.footer { text-align: center; padding: 20px 0; color: var(--text-muted); font-size: 0.85rem; margin-top: 30px; background: transparent; }
.footer-content { max-width: 1200px; margin: 0 auto; text-align: left; }
.footer-title { font-size: 1.4rem; font-weight: 700; color: var(--primary); text-align: center; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 2px solid var(--primary-light); }
.footer-section { margin-bottom: 30px; }
.footer-section h3 { font-size: 1.1rem; color: var(--primary); margin-bottom: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}
.link-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 16px; transition: all 0.3s ease;
}
.link-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--primary-light); }
.link-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.link-icon { font-size: 1.3rem; }
.link-header a { color: var(--primary); text-decoration: none; font-weight: 600; flex: 1; min-width: 120px; }
.link-header a:hover { text-decoration: underline; }
.link-badge {
    padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}
.link-badge.tested { background: var(--success-light); color: var(--success); }
.link-badge.new { background: var(--info-light); color: var(--info); }
.link-badge.no-cashback { background: var(--warning-light); color: var(--warning); }
.link-description { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; margin-top: 6px; }
.footer-copyright { padding-top: 20px; border-top: 1px solid var(--border); margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ===== TOAST & FLOATING BTN ===== */
.toast {
    position: fixed; bottom: 24px; right: 24px; background: white; padding: 14px 24px;
    border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 2000;
    transform: translateY(100px); opacity: 0; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 0.95rem; font-weight: 500; display: flex; align-items: center; gap: 10px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.success::before { content: '✓'; color: var(--success); font-weight: bold; }
.toast.error::before { content: '✗'; color: var(--danger); font-weight: bold; }
.floating-btn {
    position: fixed; bottom: 24px; right: 24px; width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white;
    border: none; font-size: 1.8rem; cursor: pointer; box-shadow: 0 4px 15px rgba(79,70,229,0.4);
    z-index: 1000; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease;
}
.floating-btn:hover { background: linear-gradient(135deg, var(--primary-dark), #3730A3); transform: scale(1.1); box-shadow: 0 6px 20px rgba(79,70,229,0.5); }
.floating-btn:active { transform: scale(0.95); }
.floating-btn span { font-size: 1.2rem; font-weight: bold; }

/* ===== ACTION BUTTONS ===== */
.action-buttons { display: flex; gap: 6px; }
.action-btn {
    padding: 6px 10px; border: none; border-radius: 6px; cursor: pointer;
    font-size: 0.85rem; transition: all 0.2s ease; display: flex; align-items: center; gap: 4px;
}
.action-btn-edit { background: var(--info); color: white; }
.action-btn-edit:hover { background: #1E40AF; }
.action-btn-delete { background: var(--danger); color: white; }
.action-btn-delete:hover { background: #DC2626; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container { padding: 15px; }
    .header { flex-direction: column; align-items: flex-start; }
    .header h1 { font-size: 1.5rem; }
    .quick-actions { flex-direction: column; }
    .btn { width: 100%; justify-content: center; }
    .totals-grid { grid-template-columns: 1fr 1fr; }
    .two-columns { grid-template-columns: 1fr; }
    .modal-content { width: 95%; padding: 25px 20px; max-height: 90vh; }
    .floating-btn { bottom: 16px; right: 16px; width: 56px; height: 56px; }
    .modal-actions { flex-direction: column; }
    .modal-actions .btn { width: 100%; }
    .links-grid { grid-template-columns: 1fr; }
    .footer-title { font-size: 1.2rem; }
}

/* ===== ANIMATIONS & SCROLLBAR ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.card, .total-card { animation: fadeIn 0.5s ease forwards; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ===== STYLES POUR BONUS.HTML ===== */
.top-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}
.top-grid .link-card { padding: 20px; }
.top-grid .link-icon { font-size: 1.5rem; }
.top-grid .link-header a { font-size: 1.1rem; }

.bonus-section { margin-bottom: 40px; }
.bonus-section h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
    display: flex;
    align-items: center;
    gap: 10px;
}
.bonus-description {
    background: var(--primary-light);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    color: var(--primary-dark);
    font-size: 0.95rem;
}

.bonus-input-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
    align-items: flex-end;
}
.bonus-select {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: white;
}
.bonus-amount {
    width: 150px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}
.bonus-result {
    background: var(--success-light);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    color: var(--success-dark);
    font-weight: 600;
    text-align: center;
}
.bonus-list {
    margin-top: 20px;
    background: var(--bg);
    padding: 15px;
    border-radius: var(--radius-sm);
}
.bonus-list table {
    width: 100%;
    font-size: 0.9rem;
}
.bonus-list th {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.bonus-list td {
    padding: 8px 12px;
}
.bonus-list tr:last-child td {
    border-bottom: none;
}