:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-bg: #f0fdf4;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --dark: #111827;
    --text: #374151;
    --text-light: #6b7280;
    --text-lighter: #9ca3af;
    --border: #e5e7eb;
    --bg: #f9fafb;
    --white: #ffffff;
    --shadow: 0 4px 24px rgba(0,0,0,.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
    --radius: 12px;
    --radius-sm: 8px;
    --header-h: 60px;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0fdf4 0%, #fef2f2 100%);
    padding: 1.5rem;
}

.auth-card {
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.75rem;
}

.auth-logo img { width: 48px; height: 48px; border-radius: 12px; }
.auth-logo span { font-size: 1.5rem; font-weight: 800; color: var(--dark); }
.auth-logo .dot { color: var(--primary); }

.auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--dark);
    text-align: center;
    margin-bottom: 0.3rem;
}

.auth-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-tabs {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    gap: 2px;
    margin-bottom: 1.5rem;
}

.auth-tab {
    flex: 1;
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--white);
    color: var(--dark);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand img { width: 36px; height: 36px; border-radius: 10px; }
.sidebar-brand span { font-size: 1.1rem; font-weight: 800; color: var(--dark); }

.team-selector {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.team-selector select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--white);
    cursor: pointer;
    color: var(--dark);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    border-radius: 0;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover { background: var(--bg); color: var(--dark); }
.nav-item.active { background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; border-right: 3px solid var(--primary); }
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

.user-mini strong { color: var(--dark); display: block; font-size: 0.9rem; }

.btn-logout {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-logout:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }

/* Main content */
.app-main {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.page-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.page-title { font-size: 1.2rem; font-weight: 700; color: var(--dark); }
.page-header .actions { display: flex; gap: 0.5rem; align-items: center; }

.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Mobile sidebar toggle */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 40;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    padding: 0.25rem;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -240px;
        top: 0;
        bottom: 0;
        z-index: 50;
        transition: left 0.25s;
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay.open { display: block; }
    .mobile-menu-btn { display: block; }
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text); margin-bottom: 0.3rem; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--dark);
    background: var(--white);
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: none; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: none; border: none; color: var(--text-light); cursor: pointer; padding: 0.4rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.85rem; }
.btn-ghost:hover { background: var(--bg); color: var(--dark); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }

/* ============================================================
   CARDS & LISTS
   ============================================================ */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-title { font-weight: 700; font-size: 1rem; color: var(--dark); }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-card .stat-val { font-size: 2rem; font-weight: 800; color: var(--dark); line-height: 1; }
.stat-card .stat-lbl { font-size: 0.78rem; color: var(--text-light); margin-top: 0.3rem; }

.list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.list-item:last-child { border-bottom: none; }
.list-item .item-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.list-item .item-info { flex: 1; min-width: 0; }
.list-item .item-title { font-weight: 600; font-size: 0.9rem; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .item-sub { font-size: 0.8rem; color: var(--text-light); margin-top: 0.15rem; }
.list-item .item-end { flex-shrink: 0; text-align: right; }

/* ============================================================
   BADGES & CHIPS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-green { background: var(--primary-bg); color: var(--primary-dark); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--bg); color: var(--text-light); }
.badge-blue { background: #eff6ff; color: #1d4ed8; }
.badge-orange { background: #fff7ed; color: #ea580c; }

/* ============================================================
   ALERT
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.alert-success { background: var(--primary-bg); color: var(--primary-dark); border: 1px solid #86efac; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { padding: 0.6rem 0.75rem; text-align: left; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); border-bottom: 2px solid var(--border); background: var(--bg); }
td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 1.75rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--dark); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-light); padding: 0.25rem; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-footer { display: flex; gap: 0.75rem; margin-top: 1.25rem; justify-content: flex-end; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty p { font-size: 0.9rem; }

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-light);
    gap: 0.75rem;
}

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--red));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ============================================================
   MEMBER ROLE COLORS
   ============================================================ */
.role-superadmin { color: #9333ea; }
.role-admin { color: #ea580c; }
.role-gestionnaire { color: #2563eb; }
.role-membre { color: var(--text-light); }

/* ============================================================
   FINANCE
   ============================================================ */
.finance-bar {
    background: var(--bg);
    border-radius: 99px;
    height: 8px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.finance-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 99px;
    transition: width 0.4s;
}

.amount-positive { color: var(--primary-dark); font-weight: 700; }
.amount-negative { color: var(--red); font-weight: 700; }
.amount-zero { color: var(--text-light); }

/* ============================================================
   TFB VOTE
   ============================================================ */
.tfb-option {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    flex: 1;
}

.tfb-option:hover { border-color: var(--primary); background: var(--primary-bg); }
.tfb-option.selected { border-color: var(--primary); background: var(--primary-bg); }
.tfb-option .tfb-emoji { font-size: 2rem; }
.tfb-options { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ============================================================
   NOTIFICATION ITEM
   ============================================================ */
.notif-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.notif-item:hover { background: var(--bg); margin: 0 -1.25rem; padding: 0.85rem 1.25rem; border-radius: var(--radius-sm); }
.notif-item.unread .notif-title { font-weight: 600; color: var(--dark); }
.notif-item .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }
.notif-item .notif-dot.read { background: transparent; }
.notif-title { font-size: 0.9rem; color: var(--text); }
.notif-body { font-size: 0.82rem; color: var(--text-light); margin-top: 0.15rem; }
.notif-time { font-size: 0.75rem; color: var(--text-lighter); }
