:root {
    --ios-bg: #f2f2f7;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --primary: #007aff;
    --primary-dark: #0056b3;
    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;
    --text-dark: #1c1c1e;
    --text-muted: #8e8e93;
    --radius-lg: 20px;
    --radius-md: 12px;
    --blur: blur(20px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-dark);
    padding-bottom: 30px;
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    padding: 20px;
    margin-bottom: 20px;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-dark);
}

.header-title i {
    font-size: 1.4rem;
    color: var(--primary);
}

.burger-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-dark);
    cursor: pointer;
    padding: 5px;
}

.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    z-index: 999;
    transition: left 0.3s cubic-bezier(0.1, 0.9, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    box-shadow: 5px 0 25px rgba(0,0,0,0.1);
}

.drawer.active {
    left: 0;
}

.drawer-header {
    padding: 30px 20px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    text-align: center;
}

.drawer-header .logo-placeholder {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary), #5ac8fa);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(0,122,255,0.3);
}

.drawer-menu {
    list-style: none;
    padding: 15px 10px;
    overflow-y: auto;
    flex-grow: 1;
}

.drawer-menu li a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    transition: background 0.2s;
}

.drawer-menu li a:hover, .drawer-menu li a.active {
    background: rgba(0, 122, 255, 0.12);
    color: var(--primary);
}

.drawer-menu li a i {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
}

.menu-divider {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 15px 15px 5px 15px;
    letter-spacing: 0.8px;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 15px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    outline: none;
    transition: border 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    border-color: var(--primary);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(120, 120, 128, 0.16);
    color: var(--text-dark);
}

.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 10px 15px; font-size: 0.9rem; width: 100%; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.kpi-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: var(--blur);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.kpi-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
}

tr.clickable-row {
    cursor: pointer;
    transition: background 0.15s;
}
tr.clickable-row:hover {
    background: rgba(0, 122, 255, 0.08);
}

.badge-mvt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.9rem;
}
.badge-entree { background: rgba(52, 199, 89, 0.15); color: var(--success); }
.badge-sortie { background: rgba(255, 59, 48, 0.15); color: var(--danger); }
.badge-fond { background: rgba(0, 122, 255, 0.15); color: var(--primary); }

.badge-statut {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
}
.statut-inactif {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.modal.active { opacity: 1; visibility: visible; }
.modal-content {
    background: rgba(255, 255, 255, 0.95);
    width: 95%;
    max-width: 680px;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    max-height: 90vh;
    overflow-y: auto;
    text-align: left;
}

.alert {
    padding: 12px 15px;
    border-radius: var(--radius-md);
    margin-bottom: 15px;
    font-size: 0.9rem;
}
.alert-success { background: rgba(52, 199, 89, 0.2); color: #155724; }
.alert-error { background: rgba(255, 59, 48, 0.2); color: #721c24; }

.flex-actions { display: flex; gap: 10px; }

.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.filter-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.filter-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
.filter-body.open { max-height: 380px; margin-top: 15px; }

.btn-qty {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,122,255,0.3);
}
.btn-qty:active {
    transform: scale(0.92);
}