:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --primary-light: #e8f0fe;
    --success: #34a853;
    --success-light: #e6f4ea;
    --warning: #fbbc04;
    --warning-light: #fef3e8;
    --danger: #ea4335;
    --danger-light: #fce8e6;
    --text: #202124;
    --text-secondary: #5f6368;
    --border: #dadce0;
    --bg: #f8f9fa;
    --card-bg: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.12);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 80px;
    font-size: 15px;
    line-height: 1.5;
}

/* ── NAV ── */
#nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--primary);
}

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

.nav-user {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── PROFILE MENU ── */
.profile-menu {
    position: fixed;
    top: 56px;
    right: 8px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    border: 1px solid var(--border);
    z-index: 200;
    min-width: 160px;
    overflow: hidden;
}

.profile-menu button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}

.profile-menu button:hover {
    background: var(--bg);
}

/* ── BOTTOM NAV ── */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    padding: 6px 16px;
    transition: var(--transition);
    flex: 1;
}

.nav-btn .icon {
    font-size: 22px;
    line-height: 1;
}

.nav-btn.active {
    color: var(--primary);
}

/* ── MAIN CONTENT ── */
#app-content {
    margin-top: 56px;
    padding: 16px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.page.hidden {
    display: none !important;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
}

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

.section {
    margin-bottom: 24px;
}

.section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

/* ── AUTH ── */
.auth-container {
    max-width: 360px;
    margin: 40px auto;
    text-align: center;
    padding: 0 16px;
}

.auth-logo {
    font-size: 64px;
    margin-bottom: 8px;
}

.auth-container h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
}

.auth-container form {
    text-align: left;
}

.auth-switch {
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* ── FORMS ── */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    transition: var(--transition);
    -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ── BUTTONS ── */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-large {
    padding: 16px;
    font-size: 16px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.btn-action {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 4px;
}

.btn-small {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-warning {
    background: var(--warning-light);
    color: #b06000;
}

.btn-danger {
    background: var(--danger-light);
    color: #c5221f;
}

.btn-success {
    background: var(--success-light);
    color: #137333;
}

/* ── STATS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

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

.stat-card:hover {
    box-shadow: var(--shadow-hover);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── CARDS ── */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

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

.card-title {
    font-weight: 600;
    font-size: 15px;
}

.card-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

.badge-active { background: var(--success-light); color: #137333; }
.badge-terminee { background: var(--warning-light); color: #b06000; }
.badge-archivee { background: #e8eaed; color: var(--text-secondary); }
.badge-planifie { background: var(--primary-light); color: var(--primary-dark); }
.badge-paye { background: var(--success-light); color: #137333; }
.badge-impaye { background: var(--danger-light); color: #c5221f; }
.badge-partiel { background: var(--warning-light); color: #b06000; }

.card-body {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

/* ── COTISATIONS GRID ── */
.cotisations-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cotisation-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
}

.cotisation-info {
    flex: 1;
}

.cotisation-name {
    font-weight: 600;
    font-size: 14px;
}

.cotisation-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.cotisation-amount {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    margin-right: 10px;
}

/* ── PROFIL ── */
.profil-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    border: 1px solid var(--border);
    text-align: center;
    margin-bottom: 24px;
}

.profil-avatar {
    font-size: 56px;
    margin-bottom: 8px;
}

.profil-name {
    font-size: 20px;
    font-weight: 700;
}

.profil-email, .profil-phone {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── MODALS ── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
    padding: 0;
}

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

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

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── TOASTS ── */
#toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: calc(100% - 32px);
    max-width: 400px;
}

.toast {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    animation: fadeInDown 0.3s ease;
    box-shadow: var(--shadow-hover);
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--primary); color: white; }

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
}

/* ── UTILS ── */
.hidden {
    display: none !important;
}

.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: #b06000; }

/* ── RESPONSIVE ── */
@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .modal-content {
        border-radius: var(--radius);
        max-width: 480px;
        margin: auto;
        animation: fadeIn 0.2s ease;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; transform: scale(0.95); }
        to { opacity: 1; transform: scale(1); }
    }
}
