:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --dark: #1a1d29;
    --sidebar: #212529;
    --bg: #f4f6f9;
    --card: #ffffff;
    --border: #dee2e6;
    --text: #212529;
    --muted: #6c757d;
    --orange: #ff6600;
    --airtel: #e40000;
    --yas: #6f42c1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d29 0%, #0d6efd 100%);
}

.login-card {
    background: var(--card);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--dark);
}

.login-logo .flag {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-brand small {
    display: block;
    font-weight: 400;
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.sidebar-nav { padding: 1rem 0; }

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.2s;
    min-height: 44px;
}

.nav-item a:hover, .nav-item a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    text-decoration: none;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 1.5rem 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.topbar h2 { font-size: 1.5rem; font-weight: 600; }

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.badge-role {
    background: var(--primary);
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 1rem; font-weight: 600; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }

.stat-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

/* Tables */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--muted);
}

table tr:hover { background: #f8f9fa; }

/* Forms */
.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #157347; color: #fff; text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bb2d3b; color: #fff; text-decoration: none; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: #f8f9fa; text-decoration: none; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.alert-error, .alert-danger { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffecb5; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-orange { background: #fff0e6; color: var(--orange); }
.badge-airtel { background: #ffe6e6; color: var(--airtel); }
.badge-yas { background: #f3e8ff; color: var(--yas); }
.badge-cash { background: #e8f5e9; color: var(--success); }

.solde-low { color: var(--danger); font-weight: 600; }

/* Operator colors in compte cards */
.comptes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.compte-card {
    background: var(--card);
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-top: 3px solid var(--primary);
}

.compte-card.orange { border-top-color: var(--orange); }
.compte-card.airtel { border-top-color: var(--airtel); }
.compte-card.yas { border-top-color: var(--yas); }
.compte-card.caisse { border-top-color: var(--success); }

.compte-card .nom { font-weight: 600; font-size: 0.95rem; }
.compte-card .numero { font-size: 0.8rem; color: var(--muted); }
.compte-card .solde { font-size: 1.25rem; font-weight: 700; margin-top: 0.5rem; }

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: #e9ecef;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}

.tab.active, .tab:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
}

.text-muted { color: var(--muted); }
.text-end { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }

@media (max-width: 768px) {
    .sidebar-toggle { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
}

/* --- Améliorations UI --- */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--sidebar);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon { font-size: 1.75rem; }

.topbar-sub { font-size: 0.85rem; color: var(--muted); margin-top: 0.15rem; }

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.user-info { display: flex; align-items: center; gap: 0.75rem; }

.btn-block { width: 100%; justify-content: center; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.grid-tx {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.25rem;
    align-items: start;
}

.bonus-preview-card { position: sticky; top: 1rem; }

.bonus-preview { padding: 0.5rem 0; }

.bonus-grid {
    display: grid;
    gap: 0.75rem;
}

.bonus-grid small { display: block; color: var(--muted); font-size: 0.75rem; }

.bonus-grid strong { font-size: 1.1rem; }

.bonus-total {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.bonus-total strong { color: var(--success); font-size: 1.25rem; }

.badge-success { background: #d1e7dd; color: #0f5132; }
.badge-danger { background: #f8d7dd; color: #842029; }

.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

.list-simple { list-style: none; padding: 0; }
.list-simple li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.form-control-sm { padding: 0.4rem 0.6rem; font-size: 0.85rem; }

.inline-form { display: inline; }

.table-hover tbody tr { transition: background 0.15s; }

.alert { transition: opacity 0.3s; }

.loading { color: var(--muted); font-style: italic; }

.nav-icon { width: 1.25rem; display: inline-block; }

.nav-logout { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.1); }

@media (max-width: 900px) {
    .grid-tx { grid-template-columns: 1fr; }
    .bonus-preview-card { position: static; }
}
